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
void adc0_read(void){
uint8_t c = 0;
+
spi1_writeWord(CH3VSGND | UNIPOLAR); // VDDDCUR
// ignore received data
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);
}
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
#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
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
\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
}\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
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
\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
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