diff --git a/main.c b/main.c --- a/main.c +++ b/main.c @@ -39,7 +39,7 @@ int main(void) Set_USBClock(); USB_Interrupts_Config(); GPIO_SetBits(LED_POWER); - //USB_Init(); // freezes here... maybe clock issue? + USB_Init(); // freezes here... maybe clock issue? RCC_ClocksTypeDef RCC_Clocks; @@ -59,9 +59,10 @@ int main(void) ssd1306_DrawPoint(3,3,1); ssd1306_DrawPoint(5,5,0); - while(1) { + ssd1306_block_write(); + // Process sensor inputs [TODO: 5hz?] process(); @@ -76,8 +77,8 @@ 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); +// SPI_I2S_SendData(SPI2,0xFA); +// SPI_I2S_SendData(SPI1,0xFA); if(!GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3)) { GPIO_ToggleBits(LED_STAT); @@ -104,7 +105,7 @@ void process() // Assert CS // This may not clock at all... might need to send 16 bits first - uint8_t retval = SPI_I2S_ReceiveData(SPI2); + uint8_t retval = 0;//SPI_I2S_ReceiveData(SPI2); // Deassert CS GPIO_SetBits(MAX_CS); diff --git a/platform_config.h b/platform_config.h --- a/platform_config.h +++ b/platform_config.h @@ -96,65 +96,9 @@ #endif /* Define the STM32F10x hardware depending on the used evaluation board */ -#ifdef USE_STM3210B_EVAL - #define USB_DISCONNECT GPIOD - #define USB_DISCONNECT_PIN GPIO_Pin_9 - #define RCC_APB2Periph_GPIO_DISCONNECT RCC_APB2Periph_GPIOD - #define EVAL_COM1_IRQHandler USART1_IRQHandler - -#elif defined (USE_STM3210E_EVAL) - #define USB_DISCONNECT GPIOB - #define USB_DISCONNECT_PIN GPIO_Pin_14 - #define RCC_APB2Periph_GPIO_DISCONNECT RCC_APB2Periph_GPIOB - #define EVAL_COM1_IRQHandler USART1_IRQHandler - - -#elif defined (USE_STM32L152_EVAL) || defined (USE_STM32L152D_EVAL) - /* - For STM32L15xx devices it is possible to use the internal USB pullup - controlled by register SYSCFG_PMC (refer to RM0038 reference manual for - more details). - It is also possible to use external pullup (and disable the internal pullup) - by setting the define USB_USE_EXTERNAL_PULLUP in file platform_config.h - and configuring the right pin to be used for the external pull up configuration. - To have more details on how to use an external pull up, please refer to - STM3210E-EVAL evaluation board manuals. - */ - /* Uncomment the following define to use an external pull up instead of the - integrated STM32L15xx internal pull up. In this case make sure to set up - correctly the external required hardware and the GPIO defines below.*/ -/* #define USB_USE_EXTERNAL_PULLUP */ - - #if !defined(USB_USE_EXTERNAL_PULLUP) - #define STM32L15_USB_CONNECT SYSCFG_USBPuCmd(ENABLE) - #define STM32L15_USB_DISCONNECT SYSCFG_USBPuCmd(DISABLE) - - #elif defined(USB_USE_EXTERNAL_PULLUP) - /* PA0 is chosen just as illustrating example, you should modify the defines - below according to your hardware configuration. */ - #define USB_DISCONNECT GPIOA - #define USB_DISCONNECT_PIN GPIO_Pin_0 - #define RCC_AHBPeriph_GPIO_DISCONNECT RCC_AHBPeriph_GPIOA - #define STM32L15_USB_CONNECT GPIO_ResetBits(USB_DISCONNECT, USB_DISCONNECT_PIN) - #define STM32L15_USB_DISCONNECT GPIO_SetBits(USB_DISCONNECT, USB_DISCONNECT_PIN) - #endif /* USB_USE_EXTERNAL_PULLUP */ - -#elif defined (USE_STM32373C_EVAL) - #define USB_DISCONNECT GPIOC - #define USB_DISCONNECT_PIN GPIO_Pin_5 - #define RCC_AHBPeriph_GPIO_DISCONNECT RCC_AHBPeriph_GPIOC - -#elif defined (USE_STM32303C_EVAL) - #define USB_DISCONNECT GPIOB - #define USB_DISCONNECT_PIN GPIO_Pin_8 - #define RCC_AHBPeriph_GPIO_DISCONNECT RCC_AHBPeriph_GPIOB -#endif /* USE_STM3210B_EVAL */ - -#if defined (USE_STM32L152_EVAL) || (USE_STM32373C_EVAL) - #define EVAL_COM1_IRQHandler USART2_IRQHandler -#elif defined (USE_STM32L152D_EVAL) || (USE_STM32303C_EVAL) - #define EVAL_COM1_IRQHandler USART1_IRQHandler -#endif +#define USB_DISCONNECT GPIOA +#define USB_DISCONNECT_PIN GPIO_Pin_10 +#define RCC_APB2Periph_GPIO_DISCONNECT RCC_APB2Periph_GPIOA /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ diff --git a/ssd1306.c b/ssd1306.c --- a/ssd1306.c +++ b/ssd1306.c @@ -92,7 +92,7 @@ void ssd1306_Init(void) *************************************************/ // Lower Column Address WriteCommand(0x00); /* Set Lower Column Address */ - GPIO_SetBits(GPIOA,GPIO_Pin_15); + GPIO_SetBits(GPIOA,GPIO_Pin_15);//turn on status LED // High Column Address WriteCommand(0x10); /* Set Higher Column Address*/ // Display Start Line @@ -164,6 +164,27 @@ void ssd1306_Init(void) // WriteCommand(0xaf); } +void ssd1306_block_write(void) +{ + + // Set col start addr to 0 + WriteCommand(0x21); + WriteCommand(0x00); + // Set col end addr to width - 1 + WriteCommand(127); + + // Set page addr + WriteCommand(0x22); + WriteCommand(0x00); // start page addr + WriteCommand(4); // end page addr (height / 8) + + + uint32_t i = 0; + for(i=0;i<1024;i++) + WriteData(ssd1306_Buffer[i]); +} + + /******************************************************************************* * Function Name : ssd1306_TurnOff * Description : Turn off the ssd1306 controller diff --git a/ssd1306.h b/ssd1306.h --- a/ssd1306.h +++ b/ssd1306.h @@ -13,5 +13,6 @@ unsigned char ssd1306_SetContrast(unsign unsigned char ssd1306_GetContrast(); unsigned char* ssd1306_GetBuffer(); unsigned long ssd1306_DrawPoint(Pos_t x, Pos_t y, Color_t color); +void ssd1306_block_write(void); #endif