summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main.c21
-rw-r--r--r503.c29
-rw-r--r--r503.h10
3 files changed, 46 insertions, 14 deletions
diff --git a/main.c b/main.c
index a7d9df2..6784d44 100644
--- a/main.c
+++ b/main.c
@@ -1,12 +1,25 @@
+#include <util/delay.h>
+
#include "r503.h"
int main(void)
{
- if (fpm_init()) {
- }
-
- while (1)
+ fpm_init();
+
+ for (;;)
{
+ fpm_led_on(RED);
+ _delay_ms(500);
+ fpm_led_off();
+ _delay_ms(500);
+ fpm_led_on(BLUE);
+ _delay_ms(500);
+ fpm_led_off();
+ _delay_ms(500);
+ fpm_led_on(PURPLE);
+ _delay_ms(500);
+ fpm_led_off();
+ _delay_ms(500);
}
return 0;
diff --git a/r503.c b/r503.c
index 3b3ac7c..cb37f32 100644
--- a/r503.c
+++ b/r503.c
@@ -126,20 +126,30 @@ static inline uint8_t check_pwd(void)
return buf[0] == OK;
}
-static inline uint8_t aura_on(void)
+void fpm_led_on(FPM_LED_COLOR color)
{
- unsigned int n;
- uint8_t buf[MAXPDLEN];
+ uint8_t buf[5];
buf[0] = 0x35;
- buf[1] = 0x01;
- buf[2] = 0x20;
- buf[3] = 0x03;
+ buf[1] = 0x03;
+ buf[2] = 0x00;
+ buf[3] = color;
+ buf[4] = 0x00;
+
+ send(0x01, buf, 5);
+}
+
+void fpm_led_off(void)
+{
+ uint8_t buf[5];
+
+ buf[0] = 0x35;
+ buf[1] = 0x04;
+ buf[2] = 0x00;
+ buf[3] = 0x00;
buf[4] = 0x00;
send(0x01, buf, 5);
- recv(buf, &n);
- return buf[0] == OK;
}
uint8_t fpm_init(void)
@@ -155,7 +165,6 @@ uint8_t fpm_init(void)
UCSR0C = (1 << UCSZ01) | (1 << UCSZ00);
_delay_ms(RST_DELAY_MS);
- aura_on();
- return check_pwd();
+ return 1;
}
diff --git a/r503.h b/r503.h
index 980fb9c..66ab5eb 100644
--- a/r503.h
+++ b/r503.h
@@ -3,6 +3,16 @@
#include <stdint.h>
+typedef enum {
+ RED = 0x01,
+ BLUE = 0x02,
+ PURPLE = 0x03
+} FPM_LED_COLOR;
+
uint8_t fpm_init(void);
+void fpm_led_on(FPM_LED_COLOR color);
+
+void fpm_led_off(void);
+
#endif /* FPM_R50_H */