]> jspc29.x-matter.uni-frankfurt.de Git - mvd_firmware.git/commitdiff
changed uart baudrate to 115200 bps, added two more debug registers
authorMichael Wiebusch <stratomaster@gmx.net>
Fri, 20 Dec 2013 15:38:03 +0000 (16:38 +0100)
committerMichael Wiebusch <stratomaster@gmx.net>
Fri, 20 Dec 2013 15:38:03 +0000 (16:38 +0100)
firmware/src/CB_functions.c
firmware/src/CB_functions.h
firmware/src/Makefile
firmware/src/main.c
firmware/src/usart1.c
firmware/src/usart1.h

index 14e24283c4c676a422f2723d1f12ef4863cd6737..7e94b3812b2122a3f29bc77a728c1a11706eaee5 100644 (file)
 
 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));
   
 }
 
@@ -76,6 +83,16 @@ void decode_register(uint8_t addr) {
         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;
       
     
   }
index 919aca24ab15718048f670492971c1b8a1df66a0..7a24ff5043f831d998d0b0f53596f197d19fb750 100644 (file)
@@ -9,10 +9,12 @@
 #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
index 24959973762104e6661b5208b91f395eb2160203..938b4bc77f9ac54abcbea416c642477c33b9510f 100644 (file)
@@ -9,6 +9,7 @@ OBJS+=periph_conf.o
 OBJS+=CB_functions.o
 OBJS+=usart1.o
 OBJS+=spi2.o
+OBJS+=misc_utils.o
 
 # OBJS+=keypins.o
 
index 72cd60c718f64231e4d3e79958c3b95caa40f8d3..59c56db93c0a36177e7459ae50bee4e6b8f6017c 100644 (file)
@@ -17,6 +17,7 @@
 #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);
 
 
 
@@ -51,44 +52,24 @@ int main(int argc, char *argv[]) {
        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;
@@ -102,7 +83,7 @@ int main(int argc, char *argv[]) {
 
 
 
-
+/*
 void SysTick_Handler(void)
 {
   
@@ -117,7 +98,7 @@ void SysTick_Handler(void)
   spi_addr=(spi_addr+1)%18;
 }
 
-
+*/
 
 
 
index e26dccaf9ae0411d2400fb69e16e38e9ce066ee0..c0962b86657f02f742a3a0e6b8da8a183b3d4048 100644 (file)
@@ -8,6 +8,14 @@
 \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
@@ -19,7 +27,7 @@ void init_USART1(void) {
   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
@@ -33,12 +41,11 @@ void init_USART1(void) {
   /* 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
@@ -70,7 +77,7 @@ void RCC_Configuration(void)
 \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
@@ -88,7 +95,7 @@ void GPIO_Configuration(void)
 \r
 \r
 /* NVIC module configuration */\r
-void NVIC_Configuration(void)\r
+static void NVIC_Configuration(void)\r
 {\r
   NVIC_InitTypeDef NVIC_InitStructure;\r
   \r
index 6166cbac006b610f177bedae931784e3fbc54962..b298e0b37201b33309029d281142621d39a8911c 100644 (file)
@@ -13,6 +13,3 @@
 \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