static const int initial_systick_count = 3;
static int systick_count;
+static int bit_count, blink_char;
+
__attribute__((isr))
void main_isr() {
+ // Initialization, since we don't blank out BSS
+ bit_count = 0;
+
// Power on the PLL, set to 16MHz XTAL
SYSCTL_RCC_R &= ~(SYSCTL_RCC_PWRDN | SYSCTL_RCC_XTAL_M);
SYSCTL_RCC_R |= SYSCTL_RCC_XTAL_16MHZ;
NVIC_ST_CURRENT_R = 0;
NVIC_ST_CTRL_R |= 0x7;
+ // Enable GPIO output for PF[3:1]
+ SYSCTL_RCGCGPIO_R |= 0x20;
+ GPIO_PORTF_DIR_R = 0xE;
+ GPIO_PORTF_DR2R_R = 0xE;
+ GPIO_PORTF_DEN_R = 0xE;
+
// infinite loop
for (;;) {
asm("wfi");
void uart0_isr() {
// Receive data, increment by 1 and send it back through the UART
int data = UART0_DR_R & 0xFF;
+ blink_char = data;
+
data = (data + 1) & 0xFF;
UART0_DR_R = data;
+
+ bit_count = 8;
}
__attribute__((isr))
// Send a character out the UART for simple testing
UART0_DR_R = 'F';
+
+ // If we're displaying bits via the LED, bit_count keeps track of how many
+ // bits are remaining to display
+ if (bit_count) {
+ if (blink_char & 0x80) {
+ // display blue for a '1' bit
+ *(GPIO_PORTF_DATA_BITS_R + 0xE) = 0x4;
+ } else {
+ // display red for a '0' bit
+ *(GPIO_PORTF_DATA_BITS_R + 0xE) = 0x2;
+ }
+ bit_count--;
+ blink_char <<= 1;
+ } else {
+ // or if we're done, blank the LED
+ *(GPIO_PORTF_DATA_BITS_R + 0xE) = 0;
+ }
}