-
-
Notifications
You must be signed in to change notification settings - Fork 62
Added additional macros/constants to sys/lcd.h and created sys/spi.h #489
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
Open
ZERICO2005
wants to merge
4
commits into
CE-Programming:master
Choose a base branch
from
ZERICO2005:enhance-sys-lcd-spi
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1a27327
Add macros/constants to sys/lcd.h and created sys/spi.h
ZERICO2005 2fa3513
Fix doxygen documentation
ZERICO2005 88b6cc6
Merge branch 'CE-Programming:master' into enhance-sys-lcd-spi
ZERICO2005 ae471c4
Refactored sys/lcd.h and sys/spi.h
ZERICO2005 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/** | ||
* @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 void*)0xF80000) | ||
#define spi_ControlRegister1 ((volatile void*)0xF80004) | ||
#define spi_ControlRegister2 ((volatile void*)0xF80008) | ||
#define spi_StatusBits ((const volatile void*)0xF8000C) | ||
#define spi_InterruptControl ((volatile void*)0xF80010) | ||
#define spi_InterruptStatus ((const volatile void*)0xF80014) | ||
#define spi_FIFO ((volatile void*)0xF80018) | ||
#define spi_InsideReservedRange ((volatile void*)0xF8001C) | ||
#define spi_Revision ((const volatile void*)0xF80060) | ||
#define spi_Features (*(const volatile uint32_t*)0xF80064) | ||
/* @endcond */ | ||
|
||
/** | ||
* In order to reliably use the LCD interface, the | ||
* boot_InitializeHardware routine should be called at the start of a program | ||
* to select the LCD interface and reset its configuration to the default. | ||
*/ | ||
#define boot_InitializeHardware() ((void(*)(void))0x384)(); | ||
|
||
/** | ||
* Sends a Command to the SPI controller using the 9bit FIFO protocol. | ||
* | ||
* @param[in] x 8bit command. | ||
*/ | ||
#define SPI_COMMAND(x) \ | ||
do { \ | ||
*(volatile uint8_t*)spi_FIFO = ((x) >> 6) & 0b111; \ | ||
*(volatile uint8_t*)spi_FIFO = ((x) >> 3) & 0b111; \ | ||
*(volatile uint8_t*)spi_FIFO = (x) & 0b111; \ | ||
*(volatile uint8_t*)spi_ControlRegister2 = 0x1; \ | ||
while ( ((const volatile uint8_t*)spi_StatusBits)[1] & 0xF0) {}; \ | ||
while ( ((const volatile uint8_t*)spi_StatusBits)[0] & (1 << 2)) {}; \ | ||
*(volatile uint8_t*)spi_ControlRegister2 = 0x0; \ | ||
} while(0) | ||
|
||
/** | ||
* Sends a Parameter to the SPI controller using the 9bit FIFO protocol. | ||
* | ||
* @param[in] x 8bit parameter. | ||
*/ | ||
#define SPI_PARAMETER(x) \ | ||
do { \ | ||
*(volatile uint8_t*)spi_FIFO = (((x) >> 6) & 0b111) | 0b100; \ | ||
*(volatile uint8_t*)spi_FIFO = ((x) >> 3) & 0b111; \ | ||
*(volatile uint8_t*)spi_FIFO = (x) & 0b111; \ | ||
*(volatile uint8_t*)spi_ControlRegister2 = 0x1; \ | ||
while ( ((const volatile uint8_t*)spi_StatusBits)[1] & 0xF0) {}; \ | ||
while ( ((const volatile uint8_t*)spi_StatusBits)[0] & (1 << 2)) {}; \ | ||
*(volatile uint8_t*)spi_ControlRegister2 = 0x0; \ | ||
} while(0) | ||
|
||
/** @todo Implement vsync */ | ||
#define SPI_UNINVERT_COLORS() SPI_COMMAND(0x20) | ||
|
||
/** @todo Implement vsync */ | ||
#define SPI_INVERT_COLORS() SPI_COMMAND(0x21) | ||
|
||
/** Sets the LCD to BGR Row-Major mode (TI-OS default) */ | ||
#define SPI_ROW_MAJOR() \ | ||
do { \ | ||
SPI_COMMAND(0x36); \ | ||
SPI_PARAMETER(0b00001000); \ | ||
SPI_COMMAND(0x2A); \ | ||
SPI_PARAMETER(0x00); SPI_PARAMETER(0x00); \ | ||
SPI_PARAMETER(0x01); SPI_PARAMETER(0x3F); \ | ||
SPI_COMMAND(0x2B); \ | ||
SPI_PARAMETER(0x00); SPI_PARAMETER(0x00); \ | ||
SPI_PARAMETER(0x00); SPI_PARAMETER(0xEF); \ | ||
} while(0) | ||
|
||
/** Sets the LCD to BGR Column-Major mode */ | ||
#define SPI_COLUMN_MAJOR() \ | ||
do { \ | ||
SPI_COMMAND(0x36); \ | ||
SPI_PARAMETER(0b00101000); \ | ||
SPI_COMMAND(0x2A); \ | ||
SPI_PARAMETER(0x00); SPI_PARAMETER(0x00); \ | ||
SPI_PARAMETER(0x00); SPI_PARAMETER(0xEF); \ | ||
SPI_COMMAND(0x2B); \ | ||
SPI_PARAMETER(0x00); SPI_PARAMETER(0x00); \ | ||
SPI_PARAMETER(0x01); SPI_PARAMETER(0x3F); \ | ||
} while(0) | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
SPI_LCD_*
instead ofSPI_*
for those?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that calc84maniac has worked on
lcddrvce
, it might be more appropriate to remove some of the SPI code