summaryrefslogtreecommitdiff
path: root/pwm.c
diff options
context:
space:
mode:
authorJohannes Kroll <jkroll@lavabit.com>2012-03-06 23:07:28 +0100
committerJohannes Kroll <jkroll@lavabit.com>2012-03-06 23:07:28 +0100
commit753680192ced57c1183588aa4b6383f06ccba4ec (patch)
tree5321ce16b1ba9955fd5887d227b141e4b104ac44 /pwm.c
parent6e1abf7e2bc054f92a38b3899968d850fbd0c7d0 (diff)
wip mult stuff
Diffstat (limited to 'pwm.c')
-rw-r--r--pwm.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/pwm.c b/pwm.c
index cf7b854..3436e9f 100644
--- a/pwm.c
+++ b/pwm.c
@@ -20,6 +20,7 @@
#include <avr/io.h>
#include <stdint.h>
#include <string.h>
+#include "shiftbrite.h"
volatile uint16_t value_red = 3072;
volatile uint16_t value_green = 2048;
@@ -32,17 +33,15 @@ void pwm_set_rgb(uint8_t r, uint8_t g, uint8_t b)
value_blue = b << 4;
}
-void pwm_worker_loop(void)
+void pwm_tick(void)
{
- for (;;) {
- for (uint16_t i = 0; i < 4096; i++) {
- // this should take about the same time for each iteration, regardless of pulse width
- PORTA= (PORTA & ~((1<<PA0)|(1<<PA1)|(1<<PA2))) |
- (value_red > i? (1<<PA0): 0) |
- (value_green > i? (1<<PA1): 0) |
- (value_blue > i? (1<<PA2): 0);
- }
- }
+ for (uint16_t i = 0; i < 4096; i++) {
+ // this should take about the same time for each iteration, regardless of pulse width
+ PORTA= (PORTA & ~((1<<PA0)|(1<<PA1)|(1<<PA2))) |
+ (value_red > i? (1<<PA0): 0) |
+ (value_green > i? (1<<PA1): 0) |
+ (value_blue > i? (1<<PA2): 0);
+ }
}
void pwm_init(void)