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

fw/hash.[ch]: new function hash_merge_progmem to read from Flash instead of RAM

This commit is contained in:
Werner Almesberger 2012-06-23 11:59:47 -03:00
parent 420370ee9c
commit a59bb00a27
2 changed files with 16 additions and 0 deletions

View File

@ -15,6 +15,8 @@
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <avr/pgmspace.h>
#include "hash.h" #include "hash.h"
@ -39,6 +41,19 @@ void hash_merge(const uint8_t *buf, uint8_t len)
} }
#ifdef __AVR__
void hash_merge_progmem(const uint8_t *buf, uint8_t len)
{
uint8_t i;
for (i = 0; i != len; i++)
hash[i & (HASH_SIZE-1)] ^= pgm_read_byte(buf+i);
}
#endif /* __AVR__ */
void hash_end(void) void hash_end(void)
{ {
} }

View File

@ -19,6 +19,7 @@
void hash_init(void); void hash_init(void);
void hash_merge(const uint8_t *buf, uint8_t len); void hash_merge(const uint8_t *buf, uint8_t len);
void hash_merge_progmem(const uint8_t *buf, uint8_t len);
void hash_end(void); void hash_end(void);
bool hash_eq(const uint8_t *buf, uint8_t len, uint8_t off); bool hash_eq(const uint8_t *buf, uint8_t len, uint8_t off);
void hash_cp(uint8_t *buf, uint8_t len, uint8_t off); void hash_cp(uint8_t *buf, uint8_t len, uint8_t off);