#include <stdio.h>
#include <stdint.h>
#define LAYERS 15
#define BYTES 4
#define CHAR_BIT 8
typedef union{
uint8_t buff8[4];
uint32_t buff32;
}led_buffer_t;
led_buffer_t LED_Buffer[LAYERS] = {0};
void shifty(uint32_t * x, uint8_t shift){
*x = (*x << shift) | (*x >> (sizeof(x)*CHAR_BIT - shift));
}
int main()
{
// simple test case
// start at 0x3, first result should be 0x80000001, then 0xc0000000, and so on
for(int i = 0; i < LAYERS; i++){
LED_Buffer[i].buff32 = 0x3;
}
for(int i = 0; i < 34; i++){
for(int j = 0; j < LAYERS; j++){
shifty(&LED_Buffer[j].buff32, 31);
printf("LED_Buffer[%d].buff32 = 0x%08x\n", j, LED_Buffer[0].buff32);
/* If you want to take a look at the bytes */
//for(int k = 0; k < BYTES; k++){
// printf("LED_Buffer[%d].buff8[%d] = 0x%02x\n", j, k, LED_Buffer[j].buff8[k]);
//}
}
}
return 0;
}