forked from jadonk/cloud9-examples
-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathbitflip.pru1_1.c
38 lines (34 loc) · 1.02 KB
/
bitflip.pru1_1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
////////////////////////////////////////
// flipbit.pru1_1.c
// Demo of shared memory
// Usage: This takes the first word of SHARED_RAM and flips every other bit
// over and over.
// Wiring: None
// Setup: Run this on a PRU and run bitflip.arm.c on the ARM using /dev/uio0.
// See:
// PRU: pru1_0 or pru1_1. Rename this file flipbit.pru1_0.c to run on the
// other pru.
////////////////////////////////////////
#include <stdint.h>
#include <pru_cfg.h>
#include <pru_ctrl.h>
#include <stddef.h>
#include <rsc_types.h>
#include "resource_table_empty.h"
#include "init_pins_empty.h"
#define SHARED_RAM_ADDRESS 0x10000
unsigned int volatile __far * const SHARED_RAM = (unsigned int *) (SHARED_RAM_ADDRESS);
void main(void) {
unsigned int value = 0;
/* Set the SHARED_RAM value to 0 */
*SHARED_RAM = 0;
while(1) {
/* Look for the ARM to modify the SHARED_RAM value */
if(value != *SHARED_RAM) {
/* Flip every other bit and write the value back */
value = *SHARED_RAM;
value ^= 0xAAAAAAAA;
*SHARED_RAM = value;
}
}
}