Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "embiosapp.h"
- void main();
- EMBIOS_APP_HEADER("LCD Test application", 0x1000, main, 127)
- #define LCDSTS (*((volatile uint32_t*)(0x3860001c)))
- #define LCDWCMD (*((volatile uint32_t*)(0x38600004)))
- #define LCDWDAT (*((volatile uint32_t*)(0x38600040)))
- #define PDAT(x) (*((volatile uint32_t*)(0x3CF00004 + (x) * 16)))
- static inline void waitlcd()
- {
- while (LCDSTS & 0x10);
- }
- static inline void waitlcdread()
- {
- while (!(LCDSTS & 1));
- }
- static inline void sendlcdc(int cmd)
- {
- waitlcd();
- LCDWCMD = cmd;
- }
- static inline void sendlcd2d(int data)
- {
- waitlcd();
- LCDWDAT = data >> 8;
- waitlcd();
- LCDWDAT = data & 0xff;
- }
- volatile bool done;
- volatile bool sync;
- void handler(enum button_event eventtype, int which, int value)
- {
- if (eventtype == BUTTON_PRESS)
- {
- if (which == 4) done = true;
- else if (which == 2) sync = false;
- else if (which == 1) sync = true;
- }
- }
- void main()
- {
- int i, j;
- button_register_handler(handler);
- sendlcdc(0x35);
- sendlcd2d(0);
- done = false;
- sync = false;
- while (!done)
- {
- for (j = 1; j < 176; j++)
- {
- if (done) break;
- while (sync && !(PDAT(8) & 1)) if (done) break;
- sendlcdc(0x2a);
- sendlcd2d(j - 1);
- sendlcd2d(j);
- sendlcdc(0x2b);
- sendlcd2d(0);
- sendlcd2d(131);
- sendlcdc(0x2c);
- for (i = 0; i < 132; i++)
- {
- sendlcd2d(0xffff);
- sendlcd2d(0);
- }
- sleep(50000);
- }
- }
- cputs(3, "Terminated\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement