uint16_t uC_regs[UC_NO_REGS];
-void report_register(uint8_t addr) {
- USART_SendData(USART1, addr); // send address
- while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
- USART_SendData(USART1, (uint8_t) (uC_regs[addr]>>8)); // upper nibble
- while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
- USART_SendData(USART1, (uint8_t) (uC_regs[addr]& 0x00FF)); // lower nibble
+
+void uart_byte_to_fpga(uint8_t byte){
+ USART_SendData(USART1, byte); // send address
while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
+}
+
+void report_register(uint8_t addr) {
+
+ // just for debug, counts number of read back operations
+ uC_regs[0x13]++;
+
+ uart_byte_to_fpga(addr);
+ uart_byte_to_fpga((uint8_t) (uC_regs[addr]>>8));
+ uart_byte_to_fpga((uint8_t) (uC_regs[addr]& 0x00FF));
}
CB_GPIO_Out(LED1,thisRegister & 1<<0);
}
break;
+
+
+ case 0x12:
+ // send single byte back to fpga!
+ uart_byte_to_fpga( (uint8_t) (thisRegister&0x00FF));
+ break;
+
+ case 0x13:
+ // do nothing
+ break;
}
#include "stm32f10x.h"
-#define UC_NO_REGS 18
+#define UC_NO_REGS 20
void init_CB_GPIO_Outputs(void);
void decode_register(uint8_t addr);
void report_register(uint8_t addr);
-void report_all_registers(void);
\ No newline at end of file
+void report_all_registers(void);
+
+void uart_byte_to_fpga(uint8_t byte);
\ No newline at end of file
OBJS+=CB_functions.o
OBJS+=usart1.o
OBJS+=spi2.o
+OBJS+=misc_utils.o
# OBJS+=keypins.o
#include "usart1.h"
#include "spi2.h"
#include "periph_conf.h"
+#include "misc_utils.h"
extern uint16_t SPIBuffer[];
extern uint16_t uC_regs[];
-GPIO_InitTypeDef GPIO_InitStructure;
-NVIC_InitTypeDef NVIC_InitStructure;
-SPI_InitTypeDef SPI_InitStructure;
-USART_InitTypeDef USART_InitStructure;
-DMA_InitTypeDef DMA_InitStructure;
+// GPIO_InitTypeDef GPIO_InitStructure;
+// NVIC_InitTypeDef NVIC_InitStructure;
+// SPI_InitTypeDef SPI_InitStructure;
+// USART_InitTypeDef USART_InitStructure;
+// DMA_InitTypeDef DMA_InitStructure;
// prototypes for functions that are included in main.c
-void SysTick_Handler(void);
+// void SysTick_Handler(void);
SystemInit();
disable_JTAG(); //disable JTAG to free GPIO ports
init_CB_GPIO_Outputs();
-
// configure timer interval
// SysTick_Config(16777215); // standard
- SysTick_Config(7200000); // 10 Hz interrupt
+// SysTick_Config(7200000); // 10 Hz interrupt
// SysTick_Config(720000); // 100 hz
// SysTick_Config(72000); // 1000 hz
- // UART init the StdPeriphLib way
-
-
-// USART_InitStructure.USART_BaudRate = 9600;
-// // USART_InitStructure.USART_BaudRate = 19200;
-// USART_InitStructure.USART_WordLength = USART_WordLength_8b;
-// USART_InitStructure.USART_StopBits = USART_StopBits_1;
-// USART_InitStructure.USART_Parity = USART_Parity_No;
-// USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
-// USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
-//
-// STM_EVAL_COMInit(COM1, &USART_InitStructure);
-// // STM_EVAL_COMInit(COM2, &USART_InitStructure);
-//
-// USART_SendData(EVAL_COM1, (uint8_t) 0);
-// USART_SendData(EVAL_COM1, (uint8_t) 1);
-// USART_SendData(EVAL_COM1, (uint8_t) 2);
-// // USART_SendData(EVAL_COM2, (uint8_t) 'B');
init_SPI2();
-// SPIBuffer[0] = 0x1234;
-// SPIBuffer[1] = 0x5678;
-
+
init_USART1();
-// report_all_registers();
-
+ delay_ms(1000);
+ CB_GPIO_Out_Hi(LED4);
+ report_all_registers();
return 0;
-
+/*
void SysTick_Handler(void)
{
spi_addr=(spi_addr+1)%18;
}
-
+*/
\r
#include "usart1.h"\r
#include "stm32f10x_conf.h"\r
+\r
+// static (private) function prototypes\r
+static void RCC_Configuration(void);\r
+static void GPIO_Configuration(void);\r
+static void NVIC_Configuration(void);\r
+\r
+\r
+\r
\r
void init_USART1(void) {\r
/* structure contains data for USART configuration */\r
NVIC_Configuration();\r
\r
/* USARTx configuration ---------------------------------------------------*/\r
- USART_InitStructure.USART_BaudRate = 9600;\r
+ USART_InitStructure.USART_BaudRate = 115200;\r
USART_InitStructure.USART_WordLength = USART_WordLength_8b;\r
USART_InitStructure.USART_StopBits = USART_StopBits_1;\r
USART_InitStructure.USART_Parity = USART_Parity_No ;\r
/* Enabling interrupt from USART1 */\r
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);\r
\r
- while (1);\r
}\r
\r
\r
/* clock sources configuration */\r
-void RCC_Configuration(void)\r
+static void RCC_Configuration(void)\r
{\r
/* error status */\r
ErrorStatus HSEStartUpStatus;\r
\r
\r
/* I/O ports configuration */\r
-void GPIO_Configuration(void)\r
+static void GPIO_Configuration(void)\r
{\r
GPIO_InitTypeDef GPIO_InitStructure;\r
\r
\r
\r
/* NVIC module configuration */\r
-void NVIC_Configuration(void)\r
+static void NVIC_Configuration(void)\r
{\r
NVIC_InitTypeDef NVIC_InitStructure;\r
\r
\r
\r
void init_USART1(void);\r
-void RCC_Configuration(void);\r
-void GPIO_Configuration(void);\r
-void NVIC_Configuration(void);
\ No newline at end of file