diff --git a/main.c b/main.c --- a/main.c +++ b/main.c @@ -20,7 +20,7 @@ #define SW_LEFT GPIOB, GPIO_Pin_5 #define SW_RIGHT GPIOB, GPIO_Pin_4 -/* Extern variables ----------------------------------------------------------*/ +// USB Supporting Vars extern __IO uint8_t Receive_Buffer[64]; extern __IO uint32_t Receive_length ; extern __IO uint32_t length ; @@ -28,8 +28,10 @@ uint8_t Send_Buffer[64]; uint32_t packet_sent=1; uint32_t packet_receive=1; + static __IO uint32_t TimingDelay; +// Move to header file void init_gpio(); void init_spi(); void process(); @@ -43,12 +45,12 @@ int main(void) init_gpio(); - Set_USBClock(); - USB_Interrupts_Config(); - USB_Init(); + // Init USB + //Set_USBClock(); + //USB_Interrupts_Config(); + //USB_Init(); GPIO_SetBits(LED_POWER); - USB_Init(); // freezes here... maybe clock issue? RCC_ClocksTypeDef RCC_Clocks; @@ -65,12 +67,34 @@ int main(void) init_spi(); ssd1306_Init(); + + ssd1306_DrawPoint(0,0,1); + ssd1306_DrawPoint(0,1,1); + ssd1306_DrawPoint(0,2,1); + ssd1306_DrawPoint(0,3,1); + ssd1306_DrawPoint(0,4,1); + ssd1306_DrawPoint(0,5,1); + ssd1306_DrawPoint(0,6,1); + + ssd1306_DrawPoint(1,3,1); + ssd1306_DrawPoint(2,3,1); ssd1306_DrawPoint(3,3,1); - ssd1306_DrawPoint(5,5,0); + ssd1306_DrawPoint(4,3,1); + + ssd1306_DrawPoint(5,0,1); + ssd1306_DrawPoint(5,1,1); + ssd1306_DrawPoint(5,2,1); + ssd1306_DrawPoint(5,3,1); + ssd1306_DrawPoint(5,4,1); + ssd1306_DrawPoint(5,5,1); + ssd1306_DrawPoint(5,6,1); + + + ssd1306_block_write(); while(1) { - ssd1306_block_write(); + //ssd1306_block_write(); // Process sensor inputs [TODO: 5hz?] process(); @@ -86,11 +110,9 @@ int main(void) uint8_t sw_left = GPIO_ReadInputDataBit(SW_LEFT); uint8_t sw_right = GPIO_ReadInputDataBit(SW_RIGHT); -// SPI_I2S_SendData(SPI2,0xFA); -// SPI_I2S_SendData(SPI1,0xFA); - - if(!GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3)) { + if(!sw_btn) { GPIO_ToggleBits(LED_STAT); + ssd1306_block_write(); } GPIO_SetBits(LED_POWER); @@ -342,7 +364,7 @@ void init_spi(void) SPI_InitStructure.SPI_CPOL = SPI_CPOL_High; SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge; SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; - SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_64; + SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_16; SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; SPI_InitStructure.SPI_CRCPolynomial = 7; SPI_Init(SPI1, &SPI_InitStructure);