Changeset - 2dc26aaf0a89
[Not reviewed]
default
0 2 0
Ethan Zonca - 10 years ago 2014-08-24 00:48:14
ez@ethanzonca.com
Move BSP code, OLED additional cleanup
2 files changed with 16 insertions and 63 deletions:
0 comments (0 inline, 0 general)
bsp.h
Show inline comments
 
#ifndef BSP_H
 
#define BSP_H
 
 
/**
 
  IO Connection map
 
 
       SSD1303
 
  Vcc   1  2  Gnd
 
D1/Data 3  4  D0/Clk
 
    D3  5  6  D2
 
    D5  7  8  D4
 
    D7  9 10  D6
 
    WR 11 12  RD
 
   RES 13 14  A0  (1-data,0-command)
 
   CS  15 16  C86 (1-8080, 0-SPI)
 
 
       STM32
 
  D0/Clk    PB13/SPI2 Clk
 
  D1/Data   PB15/SPI2 MOSI
 
  RES       PB12
 
  A0        PB14
 
  CS        Gnd
 
  D2~D7     (Float)
 
  WR        (Float)
 
  RD        (Float)
 
 */
 
 
//#define   SSD_Clk         GPIOA,GPIO_Pin_5
 
//#define   SSD_Data        GPIOA,GPIO_Pin_7
 
#define   SSD_Reset       GPIOB,GPIO_Pin_2
 
#define   SSD_A0          GPIOB,GPIO_Pin_10
 
#define   SSD_CS          GPIOB,GPIO_Pin_1
 
 
//#define   SSD_Clk_Low()     GPIO_ResetBits(GPIOA, GPIO_Pin_3)
 
//#define   SSD_Clk_High()    GPIO_SetBits(GPIOA, GPIO_Pin_5)
 
//#define   SSD_Data_Low()    GPIO_ResetBits(GPIOA, GPIO_Pin_7)
 
//#define   SSD_Data_High()   GPIO_SetBits(GPIOA, GPIO_Pin_7)
 
#define   SSD_Reset_Low()   GPIO_ResetBits(GPIOB, GPIO_Pin_2)
 
#define   SSD_Reset_High()  GPIO_SetBits(GPIOB, GPIO_Pin_2)
 
#define   SSD_A0_Low()      GPIO_ResetBits(GPIOB, GPIO_Pin_10)
 
#define   SSD_A0_High()     GPIO_SetBits(GPIOB, GPIO_Pin_10)
 
#define   SSD_CS_Low()      GPIO_ResetBits(GPIOB, GPIO_Pin_1)
 
#define   SSD_CS_High()     GPIO_SetBits(GPIOB, GPIO_Pin_1)
 
 
// Use stdperiph
 
#define   SPI_SendByte(data)  SPI_I2S_SendData(SPI1,data) 
 
#define   SPI_Wait()       while(!(SPI1->SR&SPI_I2S_FLAG_TXE));while(SPI1->SR&SPI_I2S_FLAG_BSY); 
 
#define   SSD1303_FPS                   50 
 
#define   IsLedOn()       (!(GPIOA->ODR & GPIO_Pin_8))
 
#define   LED_ON()        GPIOA->BRR = GPIO_Pin_8
 
#define   LED_OFF()       GPIOA->BSRR = GPIO_Pin_8
 
#define   ToggleLED()     if(GPIOA->ODR & GPIO_Pin_8){GPIOA->BRR = GPIO_Pin_8;}\
 
                          else{GPIOA->BSRR = GPIO_Pin_8;}
 
#define   GSel1_High()    GPIOB->BSRR = GPIO_Pin_9
 
#define   GSel1_Low()     GPIOB->BRR = GPIO_Pin_9
 
 
#define   MMA_SLEEP()     GPIOB->BRR = GPIO_Pin_11
 
#define   MMA_WAKEUP()    GPIOB->BSRR = GPIO_Pin_11
 
#define   Is_MMA_WAKEUP() (GPIOB->ODR & GPIO_Pin_11)
 
 
#define   DMA_SSD_1306    DMA1_Channel5
 
#define   DMA_Handler_SSD_1306    DMA1_Channel5_IRQHandler
 
 
 
#define   Is_Enc_Key_Down()    (!(GPIOA->IDR & GPIO_Pin_0))
 
 
#endif
ssd1306.h
Show inline comments
 
#ifndef   ssd1306_H
 
#define   ssd1306_H
 
 
#define   SSD_RESET       GPIOB,GPIO_Pin_2
 
#define   SSD_A0          GPIOB,GPIO_Pin_10
 
#define   SSD_CS          GPIOB,GPIO_Pin_1
 
 
#define   SSD_Reset_Low()   GPIO_ResetBits(SSD_RESET)
 
#define   SSD_Reset_High()  GPIO_SetBits(SSD_RESET)
 
#define   SSD_A0_Low()      GPIO_ResetBits(SSD_A0)
 
#define   SSD_A0_High()     GPIO_SetBits(SSD_A0)
 
#define   SSD_CS_Low()      GPIO_ResetBits(SSD_CS)
 
#define   SSD_CS_High()     GPIO_SetBits(SSD_CS)
 
 
// Use stdperiph
 
#define   SPI_SendByte(data)  SPI_I2S_SendData(SPI1,data) 
 
#define   SPI_Wait()       while(!(SPI1->SR&SPI_I2S_FLAG_TXE));while(SPI1->SR&SPI_I2S_FLAG_BSY); 
 
 
 
void ssd1306_Init(void);
 
void ssd1306_DrawChar(char ascii, unsigned char row, unsigned char xPos);
 
void ssd1306_DrawString(const char *dataPtr, unsigned char row, unsigned char xPos);
0 comments (0 inline, 0 general)