54 lines
1.3 KiB
C
54 lines
1.3 KiB
C
|
|
#include "fonts.h"
|
|||
|
|
#include "f28x_project.h"
|
|||
|
|
//
|
|||
|
|
// Defines
|
|||
|
|
//
|
|||
|
|
typedef unsigned char uint8_t;
|
|||
|
|
typedef unsigned short uint16_t;
|
|||
|
|
#define I2C_SLAVE_ADDRESS 0x3C
|
|||
|
|
#define I2C_OWN_ADDRESS 0x30
|
|||
|
|
#define MAX_BUFFER_SIZE 0x10
|
|||
|
|
#define I2C_NUMBYTES 0x2U
|
|||
|
|
|
|||
|
|
//
|
|||
|
|
// I2C GPIO pins
|
|||
|
|
//
|
|||
|
|
#define GPIO_PIN_SDAA 0 // GPIO number for I2C SDAA
|
|||
|
|
#define GPIO_PIN_SCLA 1 // GPIO number for I2C SCLA
|
|||
|
|
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> OLED-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
#define SSD1306_WRITECOMMAND(cmd) \
|
|||
|
|
do { \
|
|||
|
|
I2C_TXdata[0] = 0x00; \
|
|||
|
|
I2C_TXdata[1] = cmd; \
|
|||
|
|
I2CWrite(I2C_SLAVE_ADDRESS, 2, true); \
|
|||
|
|
} while (0)
|
|||
|
|
|
|||
|
|
|
|||
|
|
/* SSD1306 settings */
|
|||
|
|
/* SSD1306 width in pixels */
|
|||
|
|
#ifndef SSD1306_WIDTH
|
|||
|
|
#define SSD1306_WIDTH 128
|
|||
|
|
#endif
|
|||
|
|
/* SSD1306 LCD height in pixels */
|
|||
|
|
#ifndef SSD1306_HEIGHT
|
|||
|
|
#define SSD1306_HEIGHT 64
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief SSD1306 color enumeration
|
|||
|
|
*/
|
|||
|
|
typedef enum {
|
|||
|
|
SSD1306_COLOR_BLACK = 0x00, /*!< Black color, no pixel */
|
|||
|
|
SSD1306_COLOR_WHITE = 0x01 /*!< Pixel is set. Color depends on LCD */
|
|||
|
|
} SSD1306_COLOR_t;
|
|||
|
|
|
|||
|
|
|
|||
|
|
//
|
|||
|
|
// Function Prototypes
|
|||
|
|
//
|
|||
|
|
void I2CMaster_Init(uint16_t I2CSlave_OwnAddress, uint16_t I2CSlave_Address);
|
|||
|
|
void I2CWrite(uint16_t slaveAddr, uint16_t byteCount, bool sendStopCondition);
|
|||
|
|
uint16_t I2CRead(uint16_t slaveAddr, uint16_t byteCount, bool sendStopCondition);
|