Skip to content

Instantly share code, notes, and snippets.

@bugobliterator
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bugobliterator/c043686347d5feafc961 to your computer and use it in GitHub Desktop.
Save bugobliterator/c043686347d5feafc961 to your computer and use it in GitHub Desktop.
#define DPRAM_SHARED 0x00012000
#define NUM_RING_ENTRIES 20
/* the command is at the start of shared DPRAM */
#define RBUFF ((volatile struct ring_buffer *)DPRAM_SHARED)
struct ring_buffer {
volatile uint8_t ring_head;
volatile uint8_t ring_tail;
struct {
char str[10];
uint8_t integers[4];
} buffer[NUM_RING_ENTRIES];
};
void add_to_ring_buffer(char str[], uint32_t integers[])
{
memcpy(RBUFF->str, str, sizeof(char)*10); //check if its available on PRU, else use for loop
memcpy(RBUFF->integers, integers, sizeof(uint32_t)*3);
RBUFF->ring_tail = (RBUFF->ring_tail + 1) % NUM_RING_ENTRIES;
}
void main()
{
uint32_t deb_ints[3] = {0};
char deb_str[10] = "";
////code
strcpy(deb_str, "Fault occured"); //this
deb_ints[0] = SYSCFG; //is
add_to_ring_buffer(deb_str,deb_ints); //for debug
//continue
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment