Last active
August 29, 2015 14:17
-
-
Save bugobliterator/c043686347d5feafc961 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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