-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
drv: ft8xx: new coprocessor commands #82376
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,12 @@ | |
enum { | ||
CMD_DLSTART = 0xffffff00, | ||
CMD_SWAP = 0xffffff01, | ||
CMD_BGCOLOR = 0xffffff09, | ||
CMD_FGCOLOR = 0xffffff0a, | ||
CMD_TEXT = 0xffffff0c, | ||
CMD_SLIDER = 0xffffff10, | ||
CMD_TOGGLE = 0xffffff12, | ||
CMD_TRACK = 0xffffff2c, | ||
CMD_NUMBER = 0xffffff2e, | ||
CMD_CALIBRATE = 0xffffff15, | ||
} ft8xx_cmd; | ||
|
@@ -73,6 +78,183 @@ void ft8xx_copro_cmd_swap(void) | |
ft8xx_copro_cmd(CMD_SWAP); | ||
} | ||
|
||
void ft8xx_copro_cmd_fgcolor(uint32_t c) | ||
{ | ||
const uint16_t cmd_size = sizeof(CMD_FGCOLOR) + | ||
sizeof(c); | ||
|
||
while (ram_cmd_freespace() < cmd_size) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this function a blocking call? Probably it should be refelected in documentation as well :) same goes for other functions as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In an RTOS I expect a function to be blocking unless it's explicitly stated that it's asynchronous and described how the caller is notified when the operation ends. |
||
refresh_reg_cmd_read(); | ||
} | ||
|
||
ft8xx_wr32(FT800_RAM_CMD + reg_cmd_write, CMD_FGCOLOR); | ||
increase_reg_cmd_write(sizeof(CMD_FGCOLOR)); | ||
|
||
ft8xx_wr32(FT800_RAM_CMD + reg_cmd_write, c); | ||
increase_reg_cmd_write(sizeof(c)); | ||
|
||
flush_reg_cmd_write(); | ||
} | ||
|
||
void ft8xx_copro_cmd_bgcolor(uint32_t c) | ||
{ | ||
const uint16_t cmd_size = sizeof(CMD_BGCOLOR) + | ||
sizeof(c); | ||
|
||
while (ram_cmd_freespace() < cmd_size) { | ||
refresh_reg_cmd_read(); | ||
} | ||
|
||
ft8xx_wr32(FT800_RAM_CMD + reg_cmd_write, CMD_BGCOLOR); | ||
increase_reg_cmd_write(sizeof(CMD_BGCOLOR)); | ||
|
||
ft8xx_wr32(FT800_RAM_CMD + reg_cmd_write, c); | ||
increase_reg_cmd_write(sizeof(c)); | ||
|
||
flush_reg_cmd_write(); | ||
} | ||
|
||
void ft8xx_copro_cmd_slider(int16_t x, | ||
int16_t y, | ||
int16_t w, | ||
int16_t h, | ||
uint16_t options, | ||
uint16_t val, | ||
uint16_t range) | ||
{ | ||
size_t padding_bytes = 2; | ||
const uint16_t cmd_size = sizeof(CMD_SLIDER) + | ||
sizeof(x) + | ||
sizeof(y) + | ||
sizeof(w) + | ||
sizeof(h) + | ||
sizeof(options) + | ||
sizeof(val) + | ||
sizeof(range) + | ||
padding_bytes; | ||
|
||
while (ram_cmd_freespace() < cmd_size) { | ||
refresh_reg_cmd_read(); | ||
} | ||
|
||
ft8xx_wr32(FT800_RAM_CMD + reg_cmd_write, CMD_SLIDER); | ||
increase_reg_cmd_write(sizeof(CMD_SLIDER)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since every instance of |
||
|
||
ft8xx_wr16(FT800_RAM_CMD + reg_cmd_write, x); | ||
increase_reg_cmd_write(sizeof(x)); | ||
|
||
ft8xx_wr16(FT800_RAM_CMD + reg_cmd_write, y); | ||
increase_reg_cmd_write(sizeof(y)); | ||
|
||
ft8xx_wr16(FT800_RAM_CMD + reg_cmd_write, w); | ||
increase_reg_cmd_write(sizeof(w)); | ||
|
||
ft8xx_wr16(FT800_RAM_CMD + reg_cmd_write, h); | ||
increase_reg_cmd_write(sizeof(h)); | ||
|
||
ft8xx_wr16(FT800_RAM_CMD + reg_cmd_write, options); | ||
increase_reg_cmd_write(sizeof(options)); | ||
|
||
ft8xx_wr16(FT800_RAM_CMD + reg_cmd_write, val); | ||
increase_reg_cmd_write(sizeof(val)); | ||
|
||
ft8xx_wr16(FT800_RAM_CMD + reg_cmd_write, range); | ||
increase_reg_cmd_write(sizeof(range) + padding_bytes); | ||
|
||
flush_reg_cmd_write(); | ||
} | ||
|
||
void ft8xx_copro_cmd_toggle(int16_t x, | ||
int16_t y, | ||
int16_t w, | ||
int16_t font, | ||
uint16_t options, | ||
uint16_t state, | ||
const char *s) | ||
{ | ||
const uint16_t str_bytes = strlen(s) + 1; | ||
const uint16_t padding_bytes = (4 - (str_bytes % 4)) % 4; | ||
const uint16_t cmd_size = sizeof(CMD_TOGGLE) + | ||
sizeof(x) + | ||
sizeof(y) + | ||
sizeof(w) + | ||
sizeof(font) + | ||
sizeof(options) + | ||
sizeof(state) + | ||
str_bytes + | ||
padding_bytes; | ||
|
||
while (ram_cmd_freespace() < cmd_size) { | ||
refresh_reg_cmd_read(); | ||
} | ||
|
||
ft8xx_wr32(FT800_RAM_CMD + reg_cmd_write, CMD_TOGGLE); | ||
increase_reg_cmd_write(sizeof(CMD_TOGGLE)); | ||
|
||
ft8xx_wr16(FT800_RAM_CMD + reg_cmd_write, x); | ||
increase_reg_cmd_write(sizeof(x)); | ||
|
||
ft8xx_wr16(FT800_RAM_CMD + reg_cmd_write, y); | ||
increase_reg_cmd_write(sizeof(y)); | ||
|
||
ft8xx_wr16(FT800_RAM_CMD + reg_cmd_write, w); | ||
increase_reg_cmd_write(sizeof(w)); | ||
|
||
ft8xx_wr16(FT800_RAM_CMD + reg_cmd_write, font); | ||
increase_reg_cmd_write(sizeof(font)); | ||
|
||
ft8xx_wr16(FT800_RAM_CMD + reg_cmd_write, options); | ||
increase_reg_cmd_write(sizeof(options)); | ||
|
||
ft8xx_wr16(FT800_RAM_CMD + reg_cmd_write, state); | ||
increase_reg_cmd_write(sizeof(state)); | ||
|
||
(void)ft8xx_drv_write(FT800_RAM_CMD + reg_cmd_write, s, str_bytes); | ||
increase_reg_cmd_write(str_bytes + padding_bytes); | ||
|
||
flush_reg_cmd_write(); | ||
} | ||
|
||
void ft8xx_copro_cmd_track(int16_t x, | ||
int16_t y, | ||
int16_t w, | ||
int16_t h, | ||
int16_t tag) | ||
{ | ||
size_t padding_bytes = 2; | ||
const uint16_t cmd_size = sizeof(CMD_TRACK) + | ||
sizeof(x) + | ||
sizeof(y) + | ||
sizeof(w) + | ||
sizeof(h) + | ||
sizeof(tag) + | ||
padding_bytes; | ||
|
||
while (ram_cmd_freespace() < cmd_size) { | ||
refresh_reg_cmd_read(); | ||
} | ||
|
||
ft8xx_wr32(FT800_RAM_CMD + reg_cmd_write, CMD_TRACK); | ||
increase_reg_cmd_write(sizeof(CMD_TRACK)); | ||
|
||
ft8xx_wr16(FT800_RAM_CMD + reg_cmd_write, x); | ||
increase_reg_cmd_write(sizeof(x)); | ||
|
||
ft8xx_wr16(FT800_RAM_CMD + reg_cmd_write, y); | ||
increase_reg_cmd_write(sizeof(y)); | ||
|
||
ft8xx_wr16(FT800_RAM_CMD + reg_cmd_write, w); | ||
increase_reg_cmd_write(sizeof(w)); | ||
|
||
ft8xx_wr16(FT800_RAM_CMD + reg_cmd_write, h); | ||
increase_reg_cmd_write(sizeof(h)); | ||
|
||
ft8xx_wr16(FT800_RAM_CMD + reg_cmd_write, tag); | ||
increase_reg_cmd_write(sizeof(tag) + padding_bytes); | ||
|
||
flush_reg_cmd_write(); | ||
} | ||
|
||
void ft8xx_copro_cmd_text(int16_t x, | ||
int16_t y, | ||
int16_t font, | ||
|
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.
is c for
color
? would use the full term :)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.
I think so. It's how the programming guide defines it:
I would prefer to keep functions prototypes like in the programming guide.