Changeset - c31e71728728
[Not reviewed]
default
0 4 0
Ethan Zonca - 10 years ago 2014-08-13 23:11:50
ez@ethanzonca.com
Try getting block writing working. Also start modifying USB library. Looks like we may need to transition to a fresh USBlib download, this has freaky defines.
4 files changed with 31 insertions and 64 deletions:
0 comments (0 inline, 0 general)
main.c
Show inline comments
 
@@ -36,13 +36,13 @@ int main(void)
 
 
    init_gpio();
 
 
    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;
 
 
    // SysTick end of count event each 1ms
 
    RCC_GetClocksFreq(&RCC_Clocks);
 
    SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000);
 
@@ -56,15 +56,16 @@ int main(void)
 
    init_spi();
 
 
    ssd1306_Init();
 
    ssd1306_DrawPoint(3,3,1);
 
    ssd1306_DrawPoint(5,5,0);
 
 
 
    while(1)
 
   {  
 
        ssd1306_block_write();
 
 
        // Process sensor inputs [TODO: 5hz?]
 
        process();
 
 
        // Run state machine [TODO: 50hz?]
 
        machine(); 
 
        // probably just passed the actual port
 
@@ -73,14 +74,14 @@ int main(void)
 
        uint8_t sw_btn = GPIO_ReadInputDataBit(SW_BTN);
 
        uint8_t sw_up = GPIO_ReadInputDataBit(SW_UP);
 
        uint8_t sw_down = GPIO_ReadInputDataBit(SW_DOWN);
 
        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);
 
        }
 
 
        GPIO_SetBits(LED_POWER);
 
@@ -101,13 +102,13 @@ void process()
 
{
 
    // Read MAX temp sensor
 
    GPIO_ResetBits(MAX_CS);
 
 
    // 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);
 
 
    if((!retval || (temp & 0x2) != 0))
 
        return; // Comms error - this is happening right now
platform_config.h
Show inline comments
 
@@ -93,71 +93,15 @@
 
#define         ID2          (0x1FFFF7EC)
 
#define         ID3          (0x1FFFF7F0)
 
 
#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_PIN                  GPIO_Pin_10
 
#define RCC_APB2Periph_GPIO_DISCONNECT      RCC_APB2Periph_GPIOA
 
 
/* Exported macro ------------------------------------------------------------*/
 
/* Exported functions ------------------------------------------------------- */
 
 
#endif /* __PLATFORM_CONFIG_H */
 
ssd1306.c
Show inline comments
 
@@ -89,13 +89,13 @@ void ssd1306_Init(void)
 
  
 
  /*************************************************
 
  // ssd1306 Initialization Command
 
  *************************************************/
 
  // 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
 
  WriteCommand(0x40); /* Set Display Start Line */
 
#ifdef    DEBUG_BOARD
 
  curContrast = lastContrast = 0x30;
 
@@ -161,12 +161,33 @@ void ssd1306_Init(void)
 
//  WriteCommand(0x14); /* 0x14=ON, 0x10=Off */
 
//  
 
//  // Turn on the display
 
//  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
 
* Input          : None
 
* Output         : None
 
* Return         : None
ssd1306.h
Show inline comments
 
@@ -10,8 +10,9 @@ unsigned long ssd1306_IsOn(void);
 
unsigned long ssd1306_TurnOff(void);
 
unsigned long ssd1306_TurnOn(void);
 
unsigned char ssd1306_SetContrast(unsigned char contrast);
 
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
0 comments (0 inline, 0 general)