1
0
mirror of git://projects.qi-hardware.com/antorcha.git synced 2024-11-01 11:28:26 +02:00

tornado/fw/led.[ch]: add led_show_pgm to display row from Flash

This commit is contained in:
Werner Almesberger 2012-12-04 07:27:49 -03:00
parent 2161eec066
commit c6bef66427
2 changed files with 22 additions and 3 deletions

View File

@ -15,6 +15,7 @@
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#define F_CPU 8000000UL
#include <util/delay.h>
@ -26,7 +27,7 @@ void led_show(const uint8_t p[LED_BYTES])
{
uint8_t i;
for (i = 0; i != 8; i++) {
for (i = 0; i != LED_BYTES; i++) {
while (!(UCSR0A & (1 << UDRE0)));
UDR0 = p[i];
}
@ -52,11 +53,26 @@ void led_show(const uint8_t p[LED_BYTES])
}
void led_show_pgm(const prog_uint8_t p[LED_BYTES])
{
uint8_t i;
for (i = 0; i != LED_BYTES; i++) {
while (!(UCSR0A & (1 << UDRE0)));
UDR0 = pgm_read_byte(p+i);
}
_delay_us(4); /* 16 bits at 4 MHz */
SET(LED_LCLK);
CLR(LED_LCLK);
}
void led_off(void)
{
static uint8_t zero[LED_BYTES];
static uint8_t zero[LED_BYTES] PROGMEM = { 0, };
led_show(zero);
led_show_pgm(zero);
}

View File

@ -16,12 +16,15 @@
#include <stdint.h>
#include <avr/pgmspace.h>
#define N_LEDS 64
#define LED_BYTES (N_LEDS/8)
void led_show(const uint8_t p[LED_BYTES]);
void led_show_pgm(const prog_uint8_t p[LED_BYTES]);
void led_off(void);
void led_init(void);