add access to init script stored in progmem for avr

This commit is contained in:
matthias.ringwald@gmail.com 2014-02-04 21:42:45 +00:00
parent d1fef1900d
commit b9fe9818fd

View File

@ -52,6 +52,8 @@
* - store init script in .fartext and use assembly code to read from there
* - split into two arrays
*
* Issues with AVR
* - Harvard architecture doesn't allow to store init script directly -> use avr-libc helpers
*/
#include "bt_control_cc256x.h"
@ -64,6 +66,10 @@
#include "hal_compat.h"
#endif
#ifdef __AVR__
#include <avr/pgmspace.h>
#endif
#include "bt_control.h"
@ -201,6 +207,14 @@ static int bt_control_cc256x_next_cmd(void *config, uint8_t *hci_cmd_buffer){
int payload_len = hci_cmd_buffer[2];
FlashReadBlock(&hci_cmd_buffer[3], init_script_addr + init_script_offset, payload_len); // cmd payload
#elif defined (__AVR__)
// workaround: use memcpy_P to access init script in lower 64 kB of flash
memcpy_P(&hci_cmd_buffer[0], &cc256x_init_script[init_script_offset], 3);
init_script_offset += 3;
int payload_len = hci_cmd_buffer[2];
memcpy_P(&hci_cmd_buffer[3], &cc256x_init_script[init_script_offset], payload_len);
#else
// use memcpy with pointer