]> jspc29.x-matter.uni-frankfurt.de Git - mvd_firmware.git/commitdiff
the riddle of the lost interrupt is solved, can now repeatedly read out the adc0
authorMichael Wiebusch <antiquark@gmx.net>
Wed, 8 Jan 2014 16:52:06 +0000 (17:52 +0100)
committerMichael Wiebusch <antiquark@gmx.net>
Wed, 8 Jan 2014 16:52:06 +0000 (17:52 +0100)
firmware/src/CB_functions.c
firmware/src/CB_functions.h
firmware/src/spi2.c
firmware/src/spi2.h
firmware/src/stm32f10x_it.c
firmware/src/stm32f10x_it.h

index c28c5e861d46e5cd499e211799cbc9fe8f40fe11..0c4b9e79ffd151604f46a10d8c28eba2da1ab09b 100644 (file)
 extern uint16_t spi1DataBuffer[];
 extern uint16_t SPI_DMA_Buffer_In[];
 uint16_t uC_regs[UC_NO_REGS];
+uint16_t debug_counter = 0;
 
 
 
+void debug_out(uint16_t debu){
+  
+    // debug output => spi_debug_out
+      uC_regs[0x10]=debu;
+      report_register(0x10);
+}
+
+
 void uart_byte_to_fpga(uint8_t byte){
   while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
   USART_SendData(USART1, byte); // send address
@@ -60,6 +69,7 @@ void report_all_registers(void) {
 void adc0_read(void){
   
   uint8_t c = 0;
   
   spi1_writeWord(CH3VSGND | UNIPOLAR); // VDDDCUR
   // ignore received data
@@ -87,8 +97,10 @@ void adc0_read(void){
   spi1_writeWord(CH1VSGND | UNIPOLAR); // dummy
   SPI_DMA_Buffer_In[c++] = ZERODIFF;
   SPI_DMA_Buffer_In[c++] = spi1_receivedWord();
-  
+
   spi_dma_transfer(c);
+//   debug_out(++debug_counter);
 
 }
 
index 7a24ff5043f831d998d0b0f53596f197d19fb750..496f49feaa8dccfc292c39fedda3027ad6987a5a 100644 (file)
@@ -17,4 +17,5 @@ void decode_register(uint8_t addr);
 void report_register(uint8_t addr);
 void report_all_registers(void);
 
-void uart_byte_to_fpga(uint8_t byte);
\ No newline at end of file
+void uart_byte_to_fpga(uint8_t byte);
+void debug_out(uint16_t debu);
\ No newline at end of file
index 0255ddf6c1ce988b9a33014a62132cda35f4ea31..e69c7fd728db1dc25bfc2e5eefd95245314f1105 100644 (file)
 #include "periph_conf.h"\r
 #include "stm32f10x_conf.h"\r
 #include <string.h>\r
+#include "CB_functions.h"\r
 \r
 uint16_t SPI_DMA_Buffer[32];\r
 uint16_t SPI_DMA_Buffer_In[32];\r
 uint8_t spi_dma_busyFlag;\r
+extern uint16_t debug_counter;\r
 \r
 GPIO_InitTypeDef GPIO_InitStructure;\r
 NVIC_InitTypeDef NVIC_InitStructure;\r
@@ -97,7 +99,9 @@ void init_SPI2(void) {
   DMA_InitStructure.DMA_Priority = DMA_Priority_High;\r
   DMA_Init(DMA1_Channel5, &DMA_InitStructure);\r
   \r
-  NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel4_IRQn;\r
+  DMA_ITConfig(DMA1_Channel5, DMA_IT_TC, ENABLE); // enable transfer complete interrupt\r
+  \r
+  NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel5_IRQn;\r
   NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;\r
   NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;\r
   NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;\r
@@ -109,6 +113,7 @@ void init_SPI2(void) {
 \r
 \r
 void spi_dma_transfer(uint8_t count) {\r
+  debug_out(++debug_counter | spi_dma_busyFlag<<8);\r
 \r
   while(spi_dma_busyFlag){};\r
   \r
@@ -129,7 +134,7 @@ void spi_dma_transfer(uint8_t count) {
 }\r
 \r
 \r
-void spi_handleDMA1Ch4Interrupt(void){\r
+void spi_handleDMA1Ch5Interrupt(void){\r
   // Chip Select High\r
 //   GPIO_WriteBit(GPIOB, GPIO_Pin_12, SET);\r
     CB_GPIO_Out_Hi(UC_CS);     // spi nCS -> idle Hi\r
index 8e45b5995ffbf9d5a601aae8246dee18b2ddb3cb..3483db72a79759a6b14a87a08ee0fe59888f83ed 100644 (file)
@@ -15,4 +15,4 @@
 void init_SPI2(void);\r
 \r
 void spi_dma_transfer(uint8_t count);\r
-void spi_handleDMA1Ch4Interrupt(void);
\ No newline at end of file
+void spi_handleDMA1Ch5Interrupt(void);
\ No newline at end of file
index 6f3e5b04bd1ecf6ee9fdb7002db6eba80b55b701..351171d6c5c73682cf61abf953e4a22f99faf336 100644 (file)
@@ -62,9 +62,9 @@ void SPI1_IRQHandler(void){
 \r
 \r
 \r
-void DMA1_Channel4_IRQHandler(void){\r
-  spi_handleDMA1Ch4Interrupt();\r
-  DMA_ClearFlag(DMA1_FLAG_TC4);\r
+void DMA1_Channel5_IRQHandler(void){\r
+  spi_handleDMA1Ch5Interrupt();\r
+  DMA_ClearFlag(DMA1_FLAG_TC5);\r
 }\r
 \r
 \r
index 1e7a65e14c6b01cafda0c588ffe6e198ff09d861..0f89944114be44a1216d275838174e408b950cea 100644 (file)
@@ -45,13 +45,14 @@ void DebugMon_Handler(void);
 void PendSV_Handler(void);\r
 void SysTick_Handler(void);\r
 \r
-//for spi with dma\r
-void spi_handleDMA1Ch4Interrupt(void);\r
 \r
 //for spi1\r
 \r
 void SPI1_IRQHandler(void);\r
 \r
+// for spi2\r
+void DMA1_Channel5_IRQHandler(void);\r
+\r
 \r
 #ifdef __cplusplus\r
 }\r