Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added additional macros/constants to sys/lcd.h and created sys/spi.h #489

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 50 additions & 2 deletions src/ce/include/sys/lcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ extern "C" {
/** LCD Control register */
#define lcd_Control (*(volatile uint24_t*)0xE30018)
/* @cond */
/** LCD Bits per pixel */
#define lcd_EnableInt (*(volatile uint8_t*)0xE3001C)
#define lcd_IntStatus (*(volatile uint8_t*)0xE30020)
#define lcd_IntStatusMasked (*(volatile uint8_t*)0xE30024)
Expand All @@ -42,8 +43,8 @@ extern "C" {
/** LCD palette registers, 512 bytes */
#define lcd_Palette ((uint16_t*)0xE30200)
/* @cond */
#define lcd_CrsrImageLen32 256
#define lcd_CrsrImageLen64 1024
#define lcd_CrsrImageLen32 (256)
#define lcd_CrsrImageLen64 (1024)
#define lcd_CrsrImage ((uint8_t*)0xE30800)
#define lcd_CrsrCtrl (*(volatile uint8_t*)0xE30C00)
#define lcd_CrsrConfig (*(volatile uint8_t*)0xE30C04)
Expand Down Expand Up @@ -72,6 +73,53 @@ extern "C" {
/** Total size of VRAM in bytes */
#define LCD_SIZE (LCD_WIDTH*LCD_HEIGHT*2)

#define LCD_BGR (0x100)
#define LCD_RGB (0x000)

#define LCD_INDEXED1 (0x21) /**< 1bit indexed color */
#define LCD_INDEXED2 (0x23) /**< 2bit indexed color */
#define LCD_INDEXED4 (0x25) /**< 4bit indexed color */
#define LCD_INDEXED8 (0x27) /**< 8bit indexed color */
#define LCD_COLOR1555 (0x29) /**< 1555 16bit */
#define LCD_COLOR565 (0x2D) /**< 565 16bit */
#define LCD_COLOR444 (0x2F) /**< 444 16bit */
#define LCD_COLOR16 (LCD_COLOR565) /**< TI-OS Default */

#define LCD_BGR1bit (LCD_INDEXED1 | LCD_BGR) /**< BGR 1bit indexed color */
#define LCD_BGR2bit (LCD_INDEXED2 | LCD_BGR) /**< BGR 2bit indexed color */
#define LCD_BGR4bit (LCD_INDEXED4 | LCD_BGR) /**< BGR 4bit indexed color */
#define LCD_BGR8bit (LCD_INDEXED8 | LCD_BGR) /**< BGR 8bit indexed color */
#define LCD_BGR1555 (LCD_COLOR1555 | LCD_BGR) /**< BGR 1555 16bit */
#define LCD_BGR565 (LCD_COLOR565 | LCD_BGR) /**< BGR 565 16bit */
#define LCD_BGR444 (LCD_COLOR444 | LCD_BGR) /**< BGR 444 16bit */
#define LCD_BGR16bit (LCD_COLOR16 | LCD_BGR) /**< BGR 565 16bit (TI-OS Default) */

#define LCD_RGB1bit (LCD_INDEXED1 | LCD_RGB) /**< RGB 1bit indexed color */
#define LCD_RGB2bit (LCD_INDEXED2 | LCD_RGB) /**< RGB 2bit indexed color */
#define LCD_RGB4bit (LCD_INDEXED4 | LCD_RGB) /**< RGB 4bit indexed color */
#define LCD_RGB8bit (LCD_INDEXED8 | LCD_RGB) /**< RGB 8bit indexed color */
#define LCD_RGB1555 (LCD_COLOR1555 | LCD_RGB) /**< RGB 1555 16bit */
#define LCD_RGB565 (LCD_COLOR565 | LCD_RGB) /**< RGB 565 16bit */
#define LCD_RGB444 (LCD_COLOR444 | LCD_RGB) /**< RGB 444 16bit */
#define LCD_RGB16bit (LCD_COLOR16 | LCD_RGB) /**< RGB 565 16bit */

/**
* Sets the color order (RGB/BGR) and the bits per pixel on the LCD without
* modifying other bits.
*/
#define lcd_SetVideoMode(VideoMode) \
do { \
lcd_Control = (lcd_Control & ~0x10E) | ((VideoMode) & 0x10E); \
} while(0)

/**
* Resets lcd_Control to TI-OS defaults
*/
#define lcd_ResetVideoMode() \
do { \
lcd_Control = LCD_BGR16bit; \
} while(0)

#ifdef __cplusplus
}
#endif
Expand Down
88 changes: 88 additions & 0 deletions src/ce/include/sys/spi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/**
* @file
* @authors
* @brief CE SPI controller define file
*/

#ifndef SYS_SPI_H
#define SYS_SPI_H

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

/* @cond */
#define spi_ControlRegister0 ((volatile uint16_t*)0xF80000)
#define spi_ControlRegister1 ((volatile uint24_t*)0xF80004)
#define spi_ControlRegister2 ((volatile uint16_t*)0xF80008)

#define spi_ClockDivider ((volatile uint16_t*)0xF80004)
#define spi_DataWidth ((volatile uint8_t*)0xF80006)
#define spi_PadWidth ((volatile uint8_t*)0xF80007)

#define spi_StatusBits ((const volatile uint24_t*)0xF8000C)
#define spi_InterruptControl ((volatile uint24_t*)0xF80010)
#define spi_InterruptStatus ((const volatile uint8_t*)0xF80014)

#define spi_Fifo8 ((volatile uint8_t*)0xF80018)
#define spi_Fifo16 ((volatile uint16_t*)0xF80018)
#define spi_Fifo24 ((volatile uint24_t*)0xF80018)
#define spi_Fifo32 ((volatile uint32_t*)0xF80018)

#define spi_InsideReservedRange (*((const volatile uint32_t*)0xF8001C))
#define spi_Revision (*((const volatile uint32_t*)0xF80060))
#define spi_Features (*((const volatile uint32_t*)0xF80064))
/* @endcond */

/* spi_ControlRegister0 */

#define SPI_CLOCK_POLARITY (1 << 0)
#define SPI_CLOCK_PHASE (1 << 1)
#define SPI_SLAVE (0 << 2)
#define SPI_MASTER (3 << 2)
#define SPI_SLAVE_MONO (0 << 2)
#define SPI_SLAVE_STEREO (1 << 2)
#define SPI_MASTER_MONO (2 << 2)
#define SPI_MASTER_STEREO (3 << 2)
#define SPI_OP_MODE (3 << 2)
#define SPI_FS_JUSTIFY (1 << 4)
#define SPI_FS_POLARITY (1 << 5)
#define SPI_LSB (1 << 6)
#define SPI_LOOP_BACK (1 << 7)
#define SPI_FS_DIST (3 << 8)
#define SPI_FLASH (1 << 11)
#define SPI_FR_FORMAT (1 << 12)

/* spi_ControlRegister1 */

#define SPI_CLOCK_DIV (0xFFFF << 0)
#define SPI_DATA_WIDTH (0x1F << 0)
#define SPI_PAD_WIDTH (0xFF << 0)

/* spi_ControlRegister2 */

#define SPI_CHIP_ENABLE (1 << 0)
#define SPI_TX_DATA_OUT_ENABLE (1 << 1)
#define SPI_RX_CLEAR (1 << 2)
#define SPI_TX_CLEAR (1 << 3)
#define SPI_CHIP_RESET (1 << 6)
#define SPI_RX_ENABLE (1 << 7)
#define SPI_TX_ENABLE (1 << 8)
#define SPI_FS (1 << 9)
#define SPI_CHIP_SELECT (3 << 10)

/* spi_Fifo */

#define SPI_RX_FIFO_FULL (1 << 0)
#define SPI_TX_FIFO_NOT_FULL (1 << 1)
#define SPI_CHIP_BUSY (1 << 2)
#define SPI_RX_FIFO_BYTES (0x1F << 4)
#define SPI_TX_FIFO_BYTES (0x1F << 12)

#ifdef __cplusplus
}
#endif

#endif