Added hx8357 TFT driver for PICadillo
This commit is contained in:
259
sys/include/fonts/default.h
Normal file
259
sys/include/fonts/default.h
Normal file
@@ -0,0 +1,259 @@
|
||||
const unsigned char Default[] = {
|
||||
0x08, 0x01, 0x00, 0xFF, 1,
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x06, 0x0E, 0x1F, 0x15, 0x1F, 0x1B, 0x11, 0x0E, 0x00,
|
||||
0x06, 0x0E, 0x1F, 0x15, 0x1F, 0x11, 0x1B, 0x0E, 0x00,
|
||||
0x06, 0x00, 0x0A, 0x1F, 0x1F, 0x1F, 0x0E, 0x04, 0x00,
|
||||
0x06, 0x00, 0x04, 0x0E, 0x1F, 0x1F, 0x0E, 0x04, 0x00,
|
||||
0x06, 0x0E, 0x0A, 0x1F, 0x15, 0x1F, 0x04, 0x0E, 0x00,
|
||||
0x06, 0x04, 0x0E, 0x1F, 0x1F, 0x1F, 0x04, 0x0E, 0x00,
|
||||
0x06, 0x00, 0x00, 0x04, 0x0E, 0x0E, 0x04, 0x00, 0x00,
|
||||
0x06, 0x1F, 0x1F, 0x1B, 0x11, 0x11, 0x1B, 0x1F, 0x1F,
|
||||
0x06, 0x00, 0x00, 0x04, 0x0A, 0x0A, 0x04, 0x00, 0x00,
|
||||
0x06, 0x1F, 0x1F, 0x1B, 0x15, 0x15, 0x1B, 0x1F, 0x1F,
|
||||
0x06, 0x00, 0x1C, 0x18, 0x16, 0x05, 0x05, 0x02, 0x00,
|
||||
0x06, 0x0E, 0x11, 0x11, 0x0E, 0x04, 0x1F, 0x04, 0x00,
|
||||
0x06, 0x1E, 0x12, 0x1E, 0x02, 0x02, 0x02, 0x03, 0x00,
|
||||
0x06, 0x1E, 0x12, 0x1E, 0x12, 0x12, 0x1A, 0x03, 0x00,
|
||||
0x06, 0x04, 0x15, 0x0E, 0x1B, 0x1B, 0x0E, 0x15, 0x04,
|
||||
0x06, 0x01, 0x03, 0x0F, 0x1F, 0x0F, 0x03, 0x01, 0x00,
|
||||
0x06, 0x10, 0x18, 0x1E, 0x1F, 0x1E, 0x18, 0x10, 0x00,
|
||||
0x06, 0x04, 0x0E, 0x15, 0x04, 0x15, 0x0E, 0x04, 0x00,
|
||||
0x06, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x1B, 0x00,
|
||||
0x06, 0x1E, 0x15, 0x15, 0x16, 0x14, 0x14, 0x14, 0x00,
|
||||
0x06, 0x0C, 0x12, 0x0A, 0x14, 0x08, 0x12, 0x12, 0x0C,
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x00,
|
||||
0x06, 0x04, 0x0E, 0x15, 0x04, 0x15, 0x0E, 0x04, 0x1F,
|
||||
0x06, 0x00, 0x04, 0x0E, 0x15, 0x04, 0x04, 0x04, 0x00,
|
||||
0x06, 0x00, 0x04, 0x04, 0x04, 0x15, 0x0E, 0x04, 0x00,
|
||||
0x06, 0x00, 0x04, 0x08, 0x1F, 0x08, 0x04, 0x00, 0x00,
|
||||
0x06, 0x00, 0x04, 0x02, 0x1F, 0x02, 0x04, 0x00, 0x00,
|
||||
0x06, 0x00, 0x01, 0x01, 0x01, 0x1F, 0x00, 0x00, 0x00,
|
||||
0x06, 0x00, 0x0A, 0x1F, 0x1F, 0x0A, 0x00, 0x00, 0x00,
|
||||
0x06, 0x00, 0x04, 0x04, 0x0E, 0x1F, 0x1F, 0x00, 0x00,
|
||||
0x06, 0x00, 0x1F, 0x1F, 0x0E, 0x04, 0x04, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x04, 0x00,
|
||||
0x06, 0x0A, 0x0A, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x06, 0x0A, 0x0A, 0x1F, 0x0A, 0x1F, 0x0A, 0x0A, 0x00,
|
||||
0x06, 0x04, 0x1E, 0x05, 0x0E, 0x14, 0x0F, 0x04, 0x00,
|
||||
0x06, 0x03, 0x13, 0x08, 0x04, 0x02, 0x19, 0x18, 0x00,
|
||||
0x06, 0x02, 0x05, 0x05, 0x02, 0x15, 0x09, 0x16, 0x00,
|
||||
0x06, 0x0C, 0x0C, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00,
|
||||
0x06, 0x08, 0x04, 0x02, 0x02, 0x02, 0x04, 0x08, 0x00,
|
||||
0x06, 0x02, 0x04, 0x08, 0x08, 0x08, 0x04, 0x02, 0x00,
|
||||
0x06, 0x04, 0x15, 0x0E, 0x1F, 0x0E, 0x15, 0x04, 0x00,
|
||||
0x06, 0x00, 0x04, 0x04, 0x1F, 0x04, 0x04, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x04, 0x02,
|
||||
0x06, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00,
|
||||
0x06, 0x00, 0x10, 0x08, 0x04, 0x02, 0x01, 0x00, 0x00,
|
||||
0x06, 0x0E, 0x11, 0x19, 0x15, 0x13, 0x11, 0x0E, 0x00,
|
||||
0x06, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x0E, 0x00,
|
||||
0x06, 0x0E, 0x11, 0x10, 0x0E, 0x01, 0x01, 0x1F, 0x00,
|
||||
0x06, 0x1F, 0x10, 0x08, 0x0C, 0x10, 0x11, 0x0E, 0x00,
|
||||
0x06, 0x08, 0x0C, 0x0A, 0x09, 0x1F, 0x08, 0x08, 0x00,
|
||||
0x06, 0x1F, 0x01, 0x0F, 0x10, 0x10, 0x11, 0x0E, 0x00,
|
||||
0x06, 0x1C, 0x02, 0x01, 0x0F, 0x11, 0x11, 0x0E, 0x00,
|
||||
0x06, 0x1F, 0x10, 0x10, 0x08, 0x04, 0x02, 0x01, 0x00,
|
||||
0x06, 0x0E, 0x11, 0x11, 0x0E, 0x11, 0x11, 0x0E, 0x00,
|
||||
0x06, 0x0E, 0x11, 0x11, 0x1E, 0x10, 0x08, 0x07, 0x00,
|
||||
0x06, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x04, 0x00, 0x04, 0x04, 0x02, 0x00,
|
||||
0x06, 0x10, 0x08, 0x04, 0x02, 0x04, 0x08, 0x10, 0x00,
|
||||
0x06, 0x00, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x00, 0x00,
|
||||
0x06, 0x02, 0x04, 0x08, 0x10, 0x08, 0x04, 0x02, 0x00,
|
||||
0x06, 0x0E, 0x11, 0x10, 0x0C, 0x04, 0x00, 0x04, 0x00,
|
||||
0x06, 0x0E, 0x11, 0x15, 0x1D, 0x0D, 0x01, 0x1E, 0x00,
|
||||
0x06, 0x04, 0x0A, 0x11, 0x11, 0x1F, 0x11, 0x11, 0x00,
|
||||
0x06, 0x0F, 0x11, 0x11, 0x0F, 0x11, 0x11, 0x0F, 0x00,
|
||||
0x06, 0x0E, 0x11, 0x01, 0x01, 0x01, 0x11, 0x0E, 0x00,
|
||||
0x06, 0x0F, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0F, 0x00,
|
||||
0x06, 0x1F, 0x01, 0x01, 0x0F, 0x01, 0x01, 0x1F, 0x00,
|
||||
0x06, 0x1F, 0x01, 0x01, 0x0F, 0x01, 0x01, 0x01, 0x00,
|
||||
0x06, 0x1E, 0x11, 0x01, 0x01, 0x19, 0x11, 0x1E, 0x00,
|
||||
0x06, 0x11, 0x11, 0x11, 0x1F, 0x11, 0x11, 0x11, 0x00,
|
||||
0x06, 0x0E, 0x04, 0x04, 0x04, 0x04, 0x04, 0x0E, 0x00,
|
||||
0x06, 0x1C, 0x08, 0x08, 0x08, 0x08, 0x09, 0x06, 0x00,
|
||||
0x06, 0x11, 0x09, 0x05, 0x03, 0x05, 0x09, 0x11, 0x00,
|
||||
0x06, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x1F, 0x00,
|
||||
0x06, 0x11, 0x1B, 0x15, 0x15, 0x15, 0x11, 0x11, 0x00,
|
||||
0x06, 0x11, 0x11, 0x13, 0x15, 0x19, 0x11, 0x11, 0x00,
|
||||
0x06, 0x0E, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0E, 0x00,
|
||||
0x06, 0x0F, 0x11, 0x11, 0x0F, 0x01, 0x01, 0x01, 0x00,
|
||||
0x06, 0x0E, 0x11, 0x11, 0x11, 0x15, 0x09, 0x16, 0x00,
|
||||
0x06, 0x0F, 0x11, 0x11, 0x0F, 0x05, 0x09, 0x11, 0x00,
|
||||
0x06, 0x0E, 0x11, 0x01, 0x0E, 0x10, 0x11, 0x0E, 0x00,
|
||||
0x06, 0x1F, 0x15, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00,
|
||||
0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0E, 0x00,
|
||||
0x06, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0A, 0x04, 0x00,
|
||||
0x06, 0x11, 0x11, 0x11, 0x15, 0x15, 0x15, 0x0A, 0x00,
|
||||
0x06, 0x11, 0x11, 0x0A, 0x04, 0x0A, 0x11, 0x11, 0x00,
|
||||
0x06, 0x11, 0x11, 0x0A, 0x04, 0x04, 0x04, 0x04, 0x00,
|
||||
0x06, 0x1F, 0x10, 0x08, 0x0E, 0x02, 0x01, 0x1F, 0x00,
|
||||
0x06, 0x1E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x1E, 0x00,
|
||||
0x06, 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x00, 0x00,
|
||||
0x06, 0x1E, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1E, 0x00,
|
||||
0x06, 0x04, 0x0A, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00,
|
||||
0x06, 0x06, 0x06, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x06, 0x08, 0x0E, 0x09, 0x1E, 0x00,
|
||||
0x06, 0x01, 0x01, 0x0D, 0x13, 0x11, 0x13, 0x0D, 0x00,
|
||||
0x06, 0x00, 0x00, 0x0E, 0x11, 0x01, 0x11, 0x0E, 0x00,
|
||||
0x06, 0x10, 0x10, 0x16, 0x19, 0x11, 0x19, 0x16, 0x00,
|
||||
0x06, 0x00, 0x00, 0x0E, 0x11, 0x1F, 0x01, 0x0E, 0x00,
|
||||
0x06, 0x08, 0x14, 0x04, 0x0E, 0x04, 0x04, 0x04, 0x00,
|
||||
0x06, 0x00, 0x00, 0x0E, 0x19, 0x19, 0x16, 0x10, 0x0E,
|
||||
0x06, 0x01, 0x01, 0x0D, 0x13, 0x11, 0x11, 0x11, 0x00,
|
||||
0x06, 0x04, 0x00, 0x06, 0x04, 0x04, 0x04, 0x0E, 0x00,
|
||||
0x06, 0x08, 0x00, 0x08, 0x08, 0x08, 0x09, 0x06, 0x00,
|
||||
0x06, 0x01, 0x01, 0x09, 0x05, 0x03, 0x05, 0x09, 0x00,
|
||||
0x06, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x0E, 0x00,
|
||||
0x06, 0x00, 0x00, 0x0B, 0x15, 0x15, 0x15, 0x15, 0x00,
|
||||
0x06, 0x00, 0x00, 0x0D, 0x13, 0x11, 0x11, 0x11, 0x00,
|
||||
0x06, 0x00, 0x00, 0x0E, 0x11, 0x11, 0x11, 0x0E, 0x00,
|
||||
0x06, 0x00, 0x00, 0x0D, 0x13, 0x13, 0x0D, 0x01, 0x01,
|
||||
0x06, 0x00, 0x00, 0x16, 0x19, 0x19, 0x16, 0x10, 0x10,
|
||||
0x06, 0x00, 0x00, 0x0D, 0x13, 0x01, 0x01, 0x01, 0x00,
|
||||
0x06, 0x00, 0x00, 0x1E, 0x01, 0x0E, 0x10, 0x0F, 0x00,
|
||||
0x06, 0x04, 0x04, 0x1F, 0x04, 0x04, 0x14, 0x08, 0x00,
|
||||
0x06, 0x00, 0x00, 0x11, 0x11, 0x11, 0x19, 0x16, 0x00,
|
||||
0x06, 0x00, 0x00, 0x11, 0x11, 0x11, 0x0A, 0x04, 0x00,
|
||||
0x06, 0x00, 0x00, 0x11, 0x11, 0x15, 0x15, 0x0A, 0x00,
|
||||
0x06, 0x00, 0x00, 0x11, 0x0A, 0x04, 0x0A, 0x11, 0x00,
|
||||
0x06, 0x00, 0x00, 0x11, 0x11, 0x1E, 0x10, 0x11, 0x0E,
|
||||
0x06, 0x00, 0x00, 0x1F, 0x08, 0x04, 0x02, 0x1F, 0x00,
|
||||
0x06, 0x08, 0x04, 0x04, 0x02, 0x04, 0x04, 0x08, 0x00,
|
||||
0x06, 0x04, 0x04, 0x04, 0x00, 0x04, 0x04, 0x04, 0x00,
|
||||
0x06, 0x02, 0x04, 0x04, 0x08, 0x04, 0x04, 0x02, 0x00,
|
||||
0x06, 0x02, 0x15, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x06, 0x04, 0x0E, 0x1B, 0x11, 0x11, 0x1F, 0x00, 0x00,
|
||||
0x06, 0x0E, 0x11, 0x01, 0x01, 0x11, 0x0E, 0x08, 0x06,
|
||||
0x06, 0x00, 0x11, 0x00, 0x11, 0x11, 0x19, 0x16, 0x00,
|
||||
0x06, 0x18, 0x00, 0x0E, 0x11, 0x1F, 0x01, 0x1E, 0x00,
|
||||
0x06, 0x1F, 0x00, 0x06, 0x08, 0x0E, 0x09, 0x1E, 0x00,
|
||||
0x06, 0x11, 0x00, 0x06, 0x08, 0x0E, 0x09, 0x1E, 0x00,
|
||||
0x06, 0x03, 0x00, 0x06, 0x08, 0x0E, 0x09, 0x1E, 0x00,
|
||||
0x06, 0x0C, 0x00, 0x06, 0x08, 0x0E, 0x09, 0x1E, 0x00,
|
||||
0x06, 0x00, 0x1E, 0x03, 0x03, 0x1E, 0x08, 0x0C, 0x00,
|
||||
0x06, 0x1F, 0x00, 0x0E, 0x11, 0x1F, 0x01, 0x1E, 0x00,
|
||||
0x06, 0x11, 0x00, 0x0E, 0x11, 0x1F, 0x01, 0x1E, 0x00,
|
||||
0x06, 0x03, 0x00, 0x0E, 0x11, 0x1F, 0x01, 0x1E, 0x00,
|
||||
0x06, 0x14, 0x00, 0x0C, 0x08, 0x08, 0x08, 0x1C, 0x00,
|
||||
0x06, 0x0C, 0x12, 0x0C, 0x08, 0x08, 0x08, 0x1C, 0x00,
|
||||
0x06, 0x06, 0x00, 0x0C, 0x08, 0x08, 0x08, 0x1C, 0x00,
|
||||
0x06, 0x0A, 0x00, 0x04, 0x0A, 0x11, 0x1F, 0x11, 0x11,
|
||||
0x06, 0x04, 0x00, 0x04, 0x0A, 0x11, 0x1F, 0x11, 0x11,
|
||||
0x06, 0x0C, 0x00, 0x0F, 0x01, 0x07, 0x01, 0x0F, 0x00,
|
||||
0x06, 0x00, 0x00, 0x1E, 0x08, 0x1E, 0x09, 0x1E, 0x00,
|
||||
0x06, 0x1C, 0x0A, 0x09, 0x1F, 0x09, 0x09, 0x19, 0x00,
|
||||
0x06, 0x0E, 0x11, 0x00, 0x0E, 0x11, 0x11, 0x0E, 0x00,
|
||||
0x06, 0x00, 0x11, 0x00, 0x0E, 0x11, 0x11, 0x0E, 0x00,
|
||||
0x06, 0x00, 0x03, 0x00, 0x0E, 0x11, 0x11, 0x0E, 0x00,
|
||||
0x06, 0x0E, 0x11, 0x00, 0x11, 0x11, 0x19, 0x16, 0x00,
|
||||
0x06, 0x00, 0x03, 0x00, 0x11, 0x11, 0x19, 0x16, 0x00,
|
||||
0x06, 0x12, 0x00, 0x12, 0x12, 0x12, 0x1C, 0x10, 0x0E,
|
||||
0x06, 0x11, 0x00, 0x0E, 0x11, 0x11, 0x11, 0x0E, 0x00,
|
||||
0x06, 0x11, 0x00, 0x11, 0x11, 0x11, 0x11, 0x0E, 0x00,
|
||||
0x06, 0x04, 0x04, 0x1F, 0x05, 0x05, 0x1F, 0x04, 0x04,
|
||||
0x06, 0x0C, 0x1A, 0x12, 0x07, 0x02, 0x12, 0x1F, 0x00,
|
||||
0x06, 0x1B, 0x1B, 0x0E, 0x1F, 0x04, 0x1F, 0x04, 0x04,
|
||||
0x06, 0x07, 0x09, 0x09, 0x07, 0x09, 0x1D, 0x09, 0x09,
|
||||
0x06, 0x18, 0x14, 0x04, 0x0E, 0x04, 0x04, 0x05, 0x03,
|
||||
0x06, 0x18, 0x00, 0x06, 0x08, 0x0E, 0x09, 0x1E, 0x00,
|
||||
0x06, 0x18, 0x00, 0x0C, 0x08, 0x08, 0x08, 0x1C, 0x00,
|
||||
0x06, 0x00, 0x18, 0x00, 0x0E, 0x11, 0x11, 0x0E, 0x00,
|
||||
0x06, 0x00, 0x18, 0x00, 0x11, 0x11, 0x19, 0x16, 0x00,
|
||||
0x06, 0x00, 0x1E, 0x00, 0x0E, 0x12, 0x12, 0x12, 0x00,
|
||||
0x06, 0x1F, 0x00, 0x13, 0x17, 0x1D, 0x19, 0x11, 0x00,
|
||||
0x06, 0x0E, 0x09, 0x09, 0x1E, 0x00, 0x1F, 0x00, 0x00,
|
||||
0x06, 0x0E, 0x11, 0x11, 0x0E, 0x00, 0x1F, 0x00, 0x00,
|
||||
0x06, 0x04, 0x00, 0x04, 0x06, 0x01, 0x11, 0x0E, 0x00,
|
||||
0x06, 0x00, 0x00, 0x00, 0x1F, 0x01, 0x01, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x00, 0x1F, 0x10, 0x10, 0x00, 0x00,
|
||||
0x06, 0x01, 0x11, 0x09, 0x1D, 0x12, 0x19, 0x04, 0x1C,
|
||||
0x06, 0x01, 0x11, 0x09, 0x15, 0x1A, 0x1D, 0x10, 0x10,
|
||||
0x06, 0x04, 0x04, 0x00, 0x04, 0x04, 0x04, 0x04, 0x00,
|
||||
0x06, 0x00, 0x14, 0x0A, 0x05, 0x0A, 0x14, 0x00, 0x00,
|
||||
0x06, 0x00, 0x05, 0x0A, 0x14, 0x0A, 0x05, 0x00, 0x00,
|
||||
0x06, 0x04, 0x11, 0x04, 0x11, 0x04, 0x11, 0x04, 0x11,
|
||||
0x06, 0x0A, 0x15, 0x0A, 0x15, 0x0A, 0x15, 0x0A, 0x15,
|
||||
0x06, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
|
||||
0x06, 0x08, 0x08, 0x08, 0x08, 0x0F, 0x08, 0x08, 0x08,
|
||||
0x06, 0x08, 0x08, 0x0F, 0x08, 0x0F, 0x08, 0x08, 0x08,
|
||||
0x06, 0x14, 0x14, 0x14, 0x14, 0x17, 0x14, 0x14, 0x14,
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x14, 0x14, 0x14,
|
||||
0x06, 0x00, 0x00, 0x0F, 0x08, 0x0F, 0x08, 0x08, 0x08,
|
||||
0x06, 0x14, 0x14, 0x17, 0x10, 0x17, 0x14, 0x14, 0x14,
|
||||
0x06, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x06, 0x00, 0x00, 0x1F, 0x10, 0x17, 0x14, 0x14, 0x14,
|
||||
0x06, 0x14, 0x14, 0x17, 0x10, 0x1F, 0x00, 0x00, 0x00,
|
||||
0x06, 0x14, 0x14, 0x14, 0x14, 0x1F, 0x00, 0x00, 0x00,
|
||||
0x06, 0x08, 0x08, 0x0F, 0x08, 0x0F, 0x00, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x08, 0x08, 0x08,
|
||||
0x06, 0x08, 0x08, 0x08, 0x08, 0x18, 0x00, 0x00, 0x00,
|
||||
0x06, 0x08, 0x08, 0x08, 0x08, 0x1F, 0x00, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x08, 0x08, 0x08,
|
||||
0x06, 0x08, 0x08, 0x08, 0x08, 0x18, 0x08, 0x08, 0x08,
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00,
|
||||
0x06, 0x08, 0x08, 0x08, 0x08, 0x1F, 0x08, 0x08, 0x08,
|
||||
0x06, 0x08, 0x08, 0x18, 0x08, 0x18, 0x08, 0x08, 0x08,
|
||||
0x06, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x06, 0x14, 0x14, 0x14, 0x04, 0x1C, 0x00, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x1C, 0x04, 0x14, 0x14, 0x14, 0x14,
|
||||
0x06, 0x14, 0x14, 0x17, 0x00, 0x1F, 0x00, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x1F, 0x00, 0x17, 0x14, 0x14, 0x14,
|
||||
0x06, 0x14, 0x14, 0x14, 0x04, 0x14, 0x14, 0x14, 0x14,
|
||||
0x06, 0x00, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x00, 0x00,
|
||||
0x06, 0x14, 0x14, 0x17, 0x00, 0x17, 0x14, 0x14, 0x14,
|
||||
0x06, 0x08, 0x08, 0x1F, 0x00, 0x1F, 0x00, 0x00, 0x00,
|
||||
0x06, 0x14, 0x14, 0x14, 0x14, 0x1F, 0x00, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x1F, 0x00, 0x1F, 0x08, 0x08, 0x08,
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x14, 0x14, 0x14,
|
||||
0x06, 0x14, 0x14, 0x14, 0x14, 0x1C, 0x00, 0x00, 0x00,
|
||||
0x06, 0x08, 0x08, 0x18, 0x08, 0x18, 0x00, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x18, 0x08, 0x18, 0x08, 0x08, 0x08,
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x14, 0x14, 0x14,
|
||||
0x06, 0x14, 0x14, 0x14, 0x14, 0x1F, 0x14, 0x14, 0x14,
|
||||
0x06, 0x08, 0x08, 0x1F, 0x08, 0x1F, 0x08, 0x08, 0x08,
|
||||
0x06, 0x08, 0x08, 0x08, 0x08, 0x0F, 0x00, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x18, 0x08, 0x08, 0x08,
|
||||
0x06, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x1F, 0x1F,
|
||||
0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
|
||||
0x06, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x06, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x16, 0x09, 0x09, 0x09, 0x16, 0x00,
|
||||
0x06, 0x00, 0x0E, 0x19, 0x0F, 0x19, 0x0F, 0x01, 0x00,
|
||||
0x06, 0x00, 0x1F, 0x19, 0x01, 0x01, 0x01, 0x01, 0x00,
|
||||
0x06, 0x00, 0x1F, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x00,
|
||||
0x06, 0x1F, 0x11, 0x02, 0x04, 0x02, 0x11, 0x1F, 0x00,
|
||||
0x06, 0x00, 0x00, 0x1E, 0x09, 0x09, 0x09, 0x06, 0x00,
|
||||
0x06, 0x00, 0x0A, 0x0A, 0x0A, 0x0A, 0x16, 0x03, 0x00,
|
||||
0x06, 0x00, 0x1F, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00,
|
||||
0x06, 0x1F, 0x04, 0x0E, 0x11, 0x11, 0x0E, 0x04, 0x1F,
|
||||
0x06, 0x04, 0x0A, 0x11, 0x1F, 0x11, 0x0A, 0x04, 0x00,
|
||||
0x06, 0x04, 0x0A, 0x11, 0x11, 0x0A, 0x0A, 0x1B, 0x00,
|
||||
0x06, 0x0C, 0x02, 0x0C, 0x0E, 0x11, 0x11, 0x0E, 0x00,
|
||||
0x06, 0x00, 0x00, 0x00, 0x0E, 0x15, 0x15, 0x0E, 0x00,
|
||||
0x06, 0x10, 0x0E, 0x19, 0x15, 0x15, 0x13, 0x0E, 0x01,
|
||||
0x06, 0x0E, 0x01, 0x01, 0x0F, 0x01, 0x01, 0x0E, 0x00,
|
||||
0x06, 0x0E, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x00,
|
||||
0x06, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x00,
|
||||
0x06, 0x04, 0x04, 0x1F, 0x04, 0x04, 0x00, 0x1F, 0x00,
|
||||
0x06, 0x02, 0x04, 0x08, 0x04, 0x02, 0x00, 0x1F, 0x00,
|
||||
0x06, 0x08, 0x04, 0x02, 0x04, 0x08, 0x00, 0x1F, 0x00,
|
||||
0x06, 0x1C, 0x14, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
|
||||
0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x07,
|
||||
0x06, 0x0C, 0x0C, 0x00, 0x1F, 0x00, 0x0C, 0x0C, 0x00,
|
||||
0x06, 0x00, 0x17, 0x1D, 0x00, 0x17, 0x1D, 0x00, 0x00,
|
||||
0x06, 0x0E, 0x1B, 0x1B, 0x0E, 0x00, 0x00, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00,
|
||||
0x06, 0x1C, 0x04, 0x04, 0x04, 0x05, 0x05, 0x06, 0x04,
|
||||
0x06, 0x0E, 0x12, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00,
|
||||
0x06, 0x0E, 0x18, 0x0C, 0x06, 0x1E, 0x00, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x1E, 0x1E, 0x1E, 0x1E, 0x00, 0x00,
|
||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
2307
sys/include/fonts/topaz.h
Normal file
2307
sys/include/fonts/topaz.h
Normal file
File diff suppressed because it is too large
Load Diff
1833
sys/include/fonts/vga.h
Normal file
1833
sys/include/fonts/vga.h
Normal file
File diff suppressed because it is too large
Load Diff
21
sys/include/hx8357.h
Normal file
21
sys/include/hx8357.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef _HX8356_H
|
||||
#define _HX8357_H
|
||||
|
||||
#include "tty.h"
|
||||
|
||||
extern const struct devspec hx8357devs[];
|
||||
extern int hx8357_open(dev_t dev, int flag, int mode);
|
||||
extern int hx8357_close(dev_t dev, int flag, int mode);
|
||||
extern int hx8357_read(dev_t dev, struct uio *uio, int flag);
|
||||
extern int hx8357_write(dev_t dev, struct uio *uio, int flag);
|
||||
extern int hx8357_ioctl(dev_t dev, register u_int cmd, caddr_t addr, int flag);
|
||||
extern int hx8357_select(dev_t dev, int rw);
|
||||
extern void hx8357_putc(dev_t dev, char c);
|
||||
extern char hx8357_getc(dev_t dev);
|
||||
extern void hx8357_init();
|
||||
|
||||
|
||||
extern struct tty hx8357_ttys[1];
|
||||
|
||||
|
||||
#endif
|
||||
4
sys/pic32/cfg/hxtft.dev
Normal file
4
sys/pic32/cfg/hxtft.dev
Normal file
@@ -0,0 +1,4 @@
|
||||
always
|
||||
file hx8357.o
|
||||
define HX8357_ENABLED
|
||||
end always
|
||||
@@ -54,6 +54,10 @@ extern int strcmp(char *s1, char *s2);
|
||||
#include "pty.h"
|
||||
#endif
|
||||
|
||||
#ifdef HX8357_ENABLED
|
||||
#include "hx8357.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Null routine; placed in insignificant entries
|
||||
* in the bdevsw and cdevsw tables.
|
||||
@@ -239,6 +243,14 @@ const struct cdevsw cdevsw[] = {
|
||||
},
|
||||
#endif
|
||||
|
||||
#ifdef HX8357_ENABLED
|
||||
{
|
||||
hx8357_open, hx8357_close, hx8357_read, hx8357_write,
|
||||
hx8357_ioctl, nulldev, hx8357_ttys, hx8357_select,
|
||||
nostrategy, hx8357_getc, hx8357_putc, hx8357devs
|
||||
},
|
||||
#endif
|
||||
|
||||
// End the list with a blank entry
|
||||
{
|
||||
0, 0, 0, 0,
|
||||
|
||||
774
sys/pic32/hx8357.c
Normal file
774
sys/pic32/hx8357.c
Normal file
@@ -0,0 +1,774 @@
|
||||
/*
|
||||
* HX8357 TFT driver for PIC32.
|
||||
*
|
||||
* Copyright (C) 2014 Majenko Technologies <matt@majenko.co.uk>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software
|
||||
* and its documentation for any purpose and without fee is hereby
|
||||
* granted, provided that the above copyright notice appear in all
|
||||
* copies and that both that the copyright notice and this
|
||||
* permission notice and warranty disclaimer appear in supporting
|
||||
* documentation, and that the name of the author not be used in
|
||||
* advertising or publicity pertaining to distribution of the
|
||||
* software without specific, written prior permission.
|
||||
*
|
||||
* The author disclaim all warranties with regard to this
|
||||
* software, including all implied warranties of merchantability
|
||||
* and fitness. In no event shall the author be liable for any
|
||||
* special, indirect or consequential damages or any damages
|
||||
* whatsoever resulting from loss of use, data or profits, whether
|
||||
* in an action of contract, negligence or other tortious action,
|
||||
* arising out of or in connection with the use or performance of
|
||||
* this software.
|
||||
*/
|
||||
|
||||
#include "param.h"
|
||||
#include "conf.h"
|
||||
#include "user.h"
|
||||
#include "ioctl.h"
|
||||
#include "systm.h"
|
||||
#include "uio.h"
|
||||
#include "adc.h"
|
||||
#include "debug.h"
|
||||
#include "hx8357.h"
|
||||
|
||||
#include "fonts/default.h"
|
||||
|
||||
char frame[40][80];
|
||||
|
||||
typedef struct {
|
||||
unsigned char linesPerCharacter;
|
||||
unsigned char bytesPerLine;
|
||||
unsigned char startGlyph;
|
||||
unsigned char endGlyph;
|
||||
unsigned char bitsPerPixel;
|
||||
} FontHeader;
|
||||
|
||||
|
||||
struct tty hx8357_ttys[1];
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
unsigned short value;
|
||||
struct {
|
||||
unsigned r:5;
|
||||
unsigned g:6;
|
||||
unsigned b:5;
|
||||
} __attribute__((packed));
|
||||
} __attribute__((packed));
|
||||
} __attribute__((packed)) Color565;
|
||||
|
||||
|
||||
#define HX8357_EXIT_SLEEP_MODE 0x11
|
||||
#define HX8357_SET_DISPLAY_OFF 0x28
|
||||
#define HX8357_SET_DISPLAY_ON 0x29
|
||||
#define HX8357_SET_COLUMN_ADDRESS 0x2A
|
||||
#define HX8357_SET_PAGE_ADDRESS 0x2B
|
||||
#define HX8357_WRITE_MEMORY_START 0x2C
|
||||
#define HX8357_READ_MEMORY_START 0x2E
|
||||
#define HX8357_SET_TEAR_ON 0x35
|
||||
#define HX8357_SET_ADDRESS_MODE 0x36
|
||||
#define HX8357_SET_PIXEL_FORMAT 0x3A
|
||||
#define HX8357_WRITE_MEMORY_CONTINUE 0x3C
|
||||
#define HX8357_READ_MEMORY_CONTINUE 0x3E
|
||||
#define HX8357_SET_INTERNAL_OSCILLATOR 0xB0
|
||||
#define HX8357_SET_POWER_CONTROL 0xB1
|
||||
#define HX8357_SET_DISPLAY_MODE 0xB4
|
||||
#define HX8357_SET_VCOM_VOLTAGE 0xB6
|
||||
#define HX8357_ENABLE_EXTENSION_COMMAND 0xB9
|
||||
#define HX8357_SET_PANEL_DRIVING 0xC0 // not documented!
|
||||
#define HX8357_SET_PANEL_CHARACTERISTIC 0xCC
|
||||
#define HX8357_SET_GAMMA_CURVE 0xE0
|
||||
|
||||
static int _width = 320;
|
||||
static int _height = 480;
|
||||
|
||||
static int cursor_x = 0;
|
||||
static int cursor_y = 0;
|
||||
|
||||
static int rotation = 0;
|
||||
|
||||
static unsigned short textcolor = 0x7BEF;
|
||||
static unsigned short texthicolor = 0xFFFF;
|
||||
static unsigned short textbgcolor = 0x0000;
|
||||
|
||||
const unsigned char *font = Default;
|
||||
const unsigned char _font_width = 6;
|
||||
const unsigned char _font_height = 8;
|
||||
|
||||
const struct devspec hx8357devs[] = {
|
||||
{ 0, "tft0" },
|
||||
{ 1, "tftin0" },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
void inline static writeCommand(unsigned short c) {
|
||||
while (PMMODE & PIC32_PMMODE_BUSY);
|
||||
PMADDR = 0x0000;
|
||||
PMDIN = c;
|
||||
}
|
||||
|
||||
void inline static writeData(unsigned short c) {
|
||||
while (PMMODE & PIC32_PMMODE_BUSY);
|
||||
PMADDR = 0x0001;
|
||||
PMDIN = c;
|
||||
}
|
||||
|
||||
void initDisplay() {
|
||||
PMCONCLR = PIC32_PMCON_ON;
|
||||
asm volatile("nop");
|
||||
|
||||
PMCONSET = PIC32_PMCON_PTWREN | PIC32_PMCON_PTRDEN;
|
||||
PMCONCLR = PIC32_PMCON_CSF;
|
||||
PMAEN = 0x0001; // Enable PMA0 pin for RS pin and CS1 as CS
|
||||
PMMODE = PIC32_PMMODE_MODE16 | PIC32_PMMODE_MODE_MAST2;
|
||||
PMADDR = 0;
|
||||
PMCONSET = PIC32_PMCON_ON;
|
||||
|
||||
|
||||
writeCommand(HX8357_EXIT_SLEEP_MODE); //Sleep Out
|
||||
udelay(150000);
|
||||
writeCommand(HX8357_ENABLE_EXTENSION_COMMAND);
|
||||
writeData(0xFF);
|
||||
writeData(0x83);
|
||||
writeData(0x57);
|
||||
udelay(1000);
|
||||
writeCommand(HX8357_SET_POWER_CONTROL);
|
||||
writeData(0x00);
|
||||
writeData(0x12);
|
||||
writeData(0x12);
|
||||
writeData(0x12);
|
||||
writeData(0xC3);
|
||||
writeData(0x44);
|
||||
udelay(1000);
|
||||
writeCommand(HX8357_SET_DISPLAY_MODE);
|
||||
writeData(0x02);
|
||||
writeData(0x40);
|
||||
writeData(0x00);
|
||||
writeData(0x2A);
|
||||
writeData(0x2A);
|
||||
writeData(0x20);
|
||||
writeData(0x91);
|
||||
udelay(1000);
|
||||
writeCommand(HX8357_SET_VCOM_VOLTAGE);
|
||||
writeData(0x38);
|
||||
udelay(1000);
|
||||
writeCommand(HX8357_SET_INTERNAL_OSCILLATOR);
|
||||
writeData(0x68);
|
||||
writeCommand(0xE3); //Unknown Command
|
||||
writeData(0x2F);
|
||||
writeData(0x1F);
|
||||
writeCommand(0xB5); //Set BGP
|
||||
writeData(0x01);
|
||||
writeData(0x01);
|
||||
writeData(0x67);
|
||||
writeCommand(HX8357_SET_PANEL_DRIVING);
|
||||
writeData(0x70);
|
||||
writeData(0x70);
|
||||
writeData(0x01);
|
||||
writeData(0x3C);
|
||||
writeData(0xC8);
|
||||
writeData(0x08);
|
||||
udelay(1000);
|
||||
writeCommand(0xC2); // Set Gate EQ
|
||||
writeData(0x00);
|
||||
writeData(0x08);
|
||||
writeData(0x04);
|
||||
udelay(1000);
|
||||
writeCommand(HX8357_SET_PANEL_CHARACTERISTIC);
|
||||
writeData(0x09);
|
||||
udelay(1000);
|
||||
writeCommand(HX8357_SET_GAMMA_CURVE);
|
||||
writeData(0x01);
|
||||
writeData(0x02);
|
||||
writeData(0x03);
|
||||
writeData(0x05);
|
||||
writeData(0x0E);
|
||||
writeData(0x22);
|
||||
writeData(0x32);
|
||||
writeData(0x3B);
|
||||
writeData(0x5C);
|
||||
writeData(0x54);
|
||||
writeData(0x4C);
|
||||
writeData(0x41);
|
||||
writeData(0x3D);
|
||||
writeData(0x37);
|
||||
writeData(0x31);
|
||||
writeData(0x21);
|
||||
writeData(0x01);
|
||||
writeData(0x02);
|
||||
writeData(0x03);
|
||||
writeData(0x05);
|
||||
writeData(0x0E);
|
||||
writeData(0x22);
|
||||
writeData(0x32);
|
||||
writeData(0x3B);
|
||||
writeData(0x5C);
|
||||
writeData(0x54);
|
||||
writeData(0x4C);
|
||||
writeData(0x41);
|
||||
writeData(0x3D);
|
||||
writeData(0x37);
|
||||
writeData(0x31);
|
||||
writeData(0x21);
|
||||
writeData(0x00);
|
||||
writeData(0x01);
|
||||
udelay(1000);
|
||||
writeCommand(HX8357_SET_PIXEL_FORMAT); //COLMOD RGB888
|
||||
writeData(0x55);
|
||||
writeCommand(HX8357_SET_ADDRESS_MODE);
|
||||
writeData(0x00);
|
||||
writeCommand(HX8357_SET_TEAR_ON); //TE ON
|
||||
writeData(0x00);
|
||||
udelay(10000);
|
||||
writeCommand(HX8357_SET_DISPLAY_ON); //Display On
|
||||
udelay(10000);
|
||||
writeCommand(HX8357_WRITE_MEMORY_START); //Write SRAM Data
|
||||
int l, c;
|
||||
for (l = 0; l < 39; l++) {
|
||||
for (c = 0; c < 80; c++) {
|
||||
frame[l][c]=' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void inline static setAddrWindow(unsigned short x0, unsigned short y0, unsigned short x1, unsigned short y1) {
|
||||
writeCommand(HX8357_SET_COLUMN_ADDRESS); // Column addr set
|
||||
writeData((x0) >> 8);
|
||||
writeData(x0); // XSTART
|
||||
writeData((x1) >> 8);
|
||||
writeData(x1); // XEND
|
||||
|
||||
writeCommand(HX8357_SET_PAGE_ADDRESS); // Row addr set
|
||||
writeData((y0) >> 8);
|
||||
writeData(y0); // YSTART
|
||||
writeData((y1) >> 8);
|
||||
writeData(y1); // YEND
|
||||
|
||||
writeCommand(HX8357_WRITE_MEMORY_START); //Write SRAM Data
|
||||
}
|
||||
|
||||
void inline static setPixel(int x, int y, unsigned short color) {
|
||||
if((x < 0) ||(x >= _width) || (y < 0) || (y >= _height))
|
||||
return;
|
||||
setAddrWindow(x,y,x+1,y+1);
|
||||
while (PMMODE & PIC32_PMMODE_BUSY);
|
||||
PMADDR = 0x0001;
|
||||
PMDIN = color;
|
||||
}
|
||||
|
||||
|
||||
void inline static fillRectangle(int x, int y, int w, int h, unsigned short color)
|
||||
{
|
||||
setAddrWindow(x, y, x+w-1, y+h-1);
|
||||
|
||||
while (PMMODE & PIC32_PMMODE_BUSY);
|
||||
PMADDR = 0x0001;
|
||||
for(y=h; y>0; y--) {
|
||||
for(x=w; x>0; x--) {
|
||||
while (PMMODE & PIC32_PMMODE_BUSY);
|
||||
PMDIN = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void inline static setRotation(unsigned char m)
|
||||
{
|
||||
writeCommand(HX8357_SET_ADDRESS_MODE);
|
||||
rotation = m % 4; // can't be higher than 3
|
||||
switch (rotation)
|
||||
{
|
||||
case 0:
|
||||
//PORTRAIT
|
||||
writeData(0x0000);
|
||||
_width = 320;
|
||||
_height = 480;
|
||||
break;
|
||||
case 1:
|
||||
//LANDSCAPE
|
||||
writeData(0x0060);
|
||||
_width = 480;
|
||||
_height = 320;
|
||||
break;
|
||||
case 2:
|
||||
//UPSIDE DOWN PORTRAIT
|
||||
writeData(0x00C0);
|
||||
_width = 320;
|
||||
_height = 480;
|
||||
break;
|
||||
case 3:
|
||||
//UPSIDE DOWN LANDSCAPE
|
||||
writeData(0x00A0);
|
||||
_width = 480;
|
||||
_height = 320;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned short inline static mix(unsigned short a, unsigned short b, unsigned char pct) {
|
||||
Color565 col_a;
|
||||
Color565 col_b;
|
||||
Color565 col_out;
|
||||
col_a.value = a;
|
||||
col_b.value = b;
|
||||
unsigned int temp;
|
||||
temp = (((int)col_a.r * (255-pct)) / 255) + (((unsigned int)col_b.r * pct) / 255);
|
||||
col_out.r = temp;
|
||||
temp = (((int)col_a.g * (255-pct)) / 255) + (((unsigned int)col_b.g * pct) / 255);
|
||||
col_out.g = temp;
|
||||
temp = (((int)col_a.b * (255-pct)) / 255) + (((unsigned int)col_b.b * pct) / 255);
|
||||
col_out.b = temp;
|
||||
return col_out.value;
|
||||
}
|
||||
|
||||
|
||||
unsigned char drawChar(int x, int y, unsigned char c, unsigned short color, unsigned short bg) {
|
||||
|
||||
if (font == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
FontHeader *header = (FontHeader *)font;
|
||||
|
||||
if (c < header->startGlyph || c > header->endGlyph) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
c = c - header->startGlyph;
|
||||
|
||||
// Start of this character's data is the character number multiplied by the
|
||||
// number of lines in a character (plus one for the character width) multiplied
|
||||
// by the number of bytes in a line, and then offset by 4 for the header.
|
||||
unsigned int charstart = (c * ((header->linesPerCharacter * header->bytesPerLine) + 1)) + sizeof(FontHeader); // Start of character data
|
||||
unsigned char charwidth = font[charstart++]; // The first byte of a block is the width of the character
|
||||
|
||||
unsigned int bitmask = (1 << header->bitsPerPixel) - 1;
|
||||
|
||||
setAddrWindow(x, y, x + charwidth - 1, y + header->linesPerCharacter - 1);
|
||||
|
||||
char lineNumber = 0;
|
||||
for (lineNumber = 0; lineNumber < header->linesPerCharacter; lineNumber++ ) {
|
||||
unsigned char lineData = 0;
|
||||
|
||||
char bitsLeft = -1;
|
||||
unsigned char byteNumber = 0;
|
||||
|
||||
char pixelNumber = 0;
|
||||
for (pixelNumber = 0; pixelNumber < charwidth; pixelNumber++) {
|
||||
if (bitsLeft <= 0) {
|
||||
bitsLeft = 8;
|
||||
lineData = font[charstart + (lineNumber * header->bytesPerLine) + (header->bytesPerLine - byteNumber - 1)];
|
||||
byteNumber++;
|
||||
}
|
||||
unsigned int pixelValue = lineData & bitmask;
|
||||
if (pixelValue > 0) {
|
||||
writeData(color);
|
||||
} else {
|
||||
writeData(bg);
|
||||
}
|
||||
lineData >>= header->bitsPerPixel;
|
||||
bitsLeft -= header->bitsPerPixel;
|
||||
}
|
||||
}
|
||||
return charwidth;
|
||||
}
|
||||
|
||||
void updateLine(int l) {
|
||||
if (l < 0) return;
|
||||
if (l > 39) return;
|
||||
|
||||
int c;
|
||||
for (c = 0; c < 80; c++) {
|
||||
drawChar(c * _font_width, l * _font_height, frame[l][c] & 0x7F, frame[l][c] & 0x80 ? texthicolor : textcolor, textbgcolor);
|
||||
}
|
||||
}
|
||||
|
||||
void scrollUp() {
|
||||
int l, c;
|
||||
for (l = 0; l < 39; l++) {
|
||||
for (c = 0; c < 80; c++) {
|
||||
frame[l][c] = frame[l+1][c];
|
||||
}
|
||||
updateLine(l);
|
||||
}
|
||||
for (c = 0; c < 80; c++) {
|
||||
frame[39][c] = ' ';
|
||||
}
|
||||
updateLine(39);
|
||||
}
|
||||
|
||||
int inEscape = 0;
|
||||
|
||||
int edValPos = 0;
|
||||
int edVal[4];
|
||||
|
||||
int bold = 0;
|
||||
|
||||
void printChar(unsigned char c) {
|
||||
switch (c) {
|
||||
case '\n':
|
||||
cursor_y ++;
|
||||
if (cursor_y > 39) {
|
||||
scrollUp();
|
||||
cursor_y = 39;
|
||||
}
|
||||
break;
|
||||
case '\r':
|
||||
cursor_x = 0;
|
||||
break;
|
||||
case 8:
|
||||
cursor_x--;
|
||||
if (cursor_x < 0) {
|
||||
cursor_x = 79;
|
||||
cursor_y--;
|
||||
if (cursor_y < 0) {
|
||||
cursor_y = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
frame[cursor_y][cursor_x] = c | (bold ? 0x80 : 0x00);
|
||||
cursor_x++;
|
||||
if (cursor_x == 80) {
|
||||
cursor_x = 0;
|
||||
cursor_y++;
|
||||
if (cursor_y == 40) {
|
||||
cursor_y = 39;
|
||||
scrollUp();
|
||||
}
|
||||
}
|
||||
updateLine(cursor_y);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int extended = 0;
|
||||
|
||||
void writeChar(unsigned char c) {
|
||||
|
||||
int i, j;
|
||||
updateLine(cursor_y);
|
||||
|
||||
if (inEscape == 1) {
|
||||
|
||||
switch (c) {
|
||||
case 27:
|
||||
inEscape = 0;
|
||||
printChar('^');
|
||||
printChar('[');
|
||||
break;
|
||||
case '[':
|
||||
extended = 1;
|
||||
break;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
edVal[edValPos%4] *= 10;
|
||||
edVal[edValPos%4] += c - '0';
|
||||
break;
|
||||
case ';':
|
||||
edValPos++;
|
||||
edVal[edValPos%4] = 0;
|
||||
break;
|
||||
case 'J':
|
||||
if (extended == 1) {
|
||||
if (edVal[0] == 0) {
|
||||
for (i = cursor_y; i < 40; i++) {
|
||||
for (j = 0; j < 80; j++) {
|
||||
frame[i][j] = ' ';
|
||||
}
|
||||
updateLine(i);
|
||||
}
|
||||
} else if (edVal[0] == 1) {
|
||||
for (i = 0; i < cursor_y; i++) {
|
||||
for (j = 0; j < 80; j++) {
|
||||
frame[i][j] = ' ';
|
||||
}
|
||||
updateLine(i);
|
||||
}
|
||||
} else if (edVal[0] == 2) {
|
||||
for (i = 0; i < 40; i++) {
|
||||
for (j = 0; j < 80; j++) {
|
||||
frame[i][j] = ' ';
|
||||
}
|
||||
updateLine(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
inEscape = 0;
|
||||
break;
|
||||
case 'H':
|
||||
if (extended == 1) {
|
||||
if (edVal[0] == 0) {
|
||||
edVal[0] = 1;
|
||||
}
|
||||
if (edVal[1] == 0) {
|
||||
edVal[1] = 1;
|
||||
}
|
||||
cursor_x = (edVal[1] - 1) % 80;
|
||||
cursor_y = (edVal[0] - 1) % 40;
|
||||
}
|
||||
inEscape = 0;
|
||||
break;
|
||||
case 'm':
|
||||
if (extended == 1) {
|
||||
if (edVal[0] == 0) {
|
||||
bold = 0;
|
||||
} else if (edVal[0] == 1) {
|
||||
bold = 1;
|
||||
}
|
||||
}
|
||||
inEscape = 0;
|
||||
break;
|
||||
|
||||
case 'A':
|
||||
if (extended == 0) {
|
||||
cursor_y--;
|
||||
if (cursor_y > 0) {
|
||||
cursor_y = 39;
|
||||
}
|
||||
}
|
||||
inEscape = 0;
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
if (extended == 0) {
|
||||
cursor_y++;
|
||||
if (cursor_y == 40) {
|
||||
cursor_y = 0;
|
||||
}
|
||||
}
|
||||
inEscape = 0;
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
if (extended == 0) {
|
||||
cursor_x++;
|
||||
if (cursor_x == 80) {
|
||||
cursor_x = 0;
|
||||
cursor_y++;
|
||||
if (cursor_y == 40) {
|
||||
cursor_y = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
inEscape = 0;
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
if (extended == 0) {
|
||||
cursor_x--;
|
||||
if (cursor_x < 0) {
|
||||
cursor_x = 79;
|
||||
cursor_y--;
|
||||
if (cursor_y < 0) {
|
||||
cursor_y = 39;
|
||||
}
|
||||
}
|
||||
}
|
||||
inEscape = 0;
|
||||
break;
|
||||
|
||||
case 'K':
|
||||
if (extended == 1) {
|
||||
if (edVal[0] == 0) {
|
||||
for (i = cursor_x; i < 80; i++) {
|
||||
frame[cursor_y][i] = ' ';
|
||||
}
|
||||
} else if (edVal[1] == 1) {
|
||||
for (i = 0; i < cursor_x; i++) {
|
||||
frame[cursor_y][i] = ' ';
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < 80; i++) {
|
||||
frame[cursor_y][i] = ' ';
|
||||
}
|
||||
}
|
||||
updateLine(cursor_y);
|
||||
}
|
||||
inEscape = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (extended) {
|
||||
printf("Unhandled extended escape code %c\n", c);
|
||||
} else {
|
||||
printf("Unhandled escape code %c\n", c);
|
||||
}
|
||||
inEscape = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (c == 27) {
|
||||
inEscape = 1;
|
||||
extended = 0;
|
||||
edVal[0] = 0;
|
||||
edValPos = 0;
|
||||
} else {
|
||||
printChar(c);
|
||||
}
|
||||
}
|
||||
drawChar(cursor_x * _font_width, cursor_y * _font_height, frame[cursor_y][cursor_x] & 0x7F, 0x0000, bold ? texthicolor : textcolor);
|
||||
// for (i = 0; i < _font_width; i++) {
|
||||
// setPixel(cursor_x * _font_width + i, (cursor_y + 1) * _font_height - 1, 0xFFFF);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
void hx8357_start(struct tty *tp) {
|
||||
register int s;
|
||||
|
||||
s = spltty();
|
||||
ttyowake(tp);
|
||||
// tp->t_state &= TS_BUSY;
|
||||
if (tp->t_outq.c_cc > 0) {
|
||||
led_control (LED_TTY, 1);
|
||||
while (tp->t_outq.c_cc != 0) {
|
||||
int c = getc (&tp->t_outq);
|
||||
writeChar(c);
|
||||
}
|
||||
led_control (LED_TTY, 0);
|
||||
}
|
||||
// tp->t_state |= TS_BUSY;
|
||||
splx (s);
|
||||
}
|
||||
|
||||
void hx8357_init() {
|
||||
initDisplay();
|
||||
setRotation(1);
|
||||
int i,j;
|
||||
for (i = 0; i < 40; i++) {
|
||||
for (j = 0; j < 80; j++) {
|
||||
frame[i][j] = ' ';
|
||||
}
|
||||
updateLine(i);
|
||||
}
|
||||
}
|
||||
|
||||
int ttyIsOpen = 0;
|
||||
|
||||
int hx8357_open(dev_t dev, int flag, int mode) {
|
||||
int unit = minor(dev);
|
||||
|
||||
if (unit == 0) {
|
||||
ttyIsOpen = 1;
|
||||
struct tty *tp = &hx8357_ttys[0];
|
||||
tp->t_oproc = hx8357_start;
|
||||
tp->t_state = TS_ISOPEN | TS_CARR_ON;
|
||||
tp->t_flags = ECHO | XTABS | CRMOD | CRTBS | CRTERA | CTLECH | CRTKIL;
|
||||
return ttyopen(dev, tp);
|
||||
}
|
||||
if (unit == 1) {
|
||||
if (!ttyIsOpen) {
|
||||
return EIO;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return ENODEV;
|
||||
}
|
||||
|
||||
int hx8357_close(dev_t dev, int flag, int mode) {
|
||||
int unit = minor(dev);
|
||||
|
||||
if (unit == 0) {
|
||||
ttyIsOpen = 0;
|
||||
struct tty *tp = &hx8357_ttys[0];
|
||||
ttyclose(tp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (unit == 1) {
|
||||
return 0;
|
||||
}
|
||||
return ENODEV;
|
||||
}
|
||||
|
||||
int hx8357_read(dev_t dev, struct uio *uio, int flag) {
|
||||
int unit = minor(dev);
|
||||
|
||||
if (unit == 0) {
|
||||
struct tty *tp = &hx8357_ttys[unit];
|
||||
return ttread(tp, uio, flag);
|
||||
}
|
||||
if (unit == 1) {
|
||||
return EIO;
|
||||
}
|
||||
|
||||
return ENODEV;
|
||||
}
|
||||
|
||||
int hx8357_write(dev_t dev, struct uio *uio, int flag) {
|
||||
int unit = minor(dev);
|
||||
|
||||
if (unit == 0) {
|
||||
struct tty *tp = &hx8357_ttys[0];
|
||||
return ttwrite(tp, uio, flag);
|
||||
}
|
||||
|
||||
if (unit == 1) {
|
||||
if (!ttyIsOpen) {
|
||||
return EIO;
|
||||
}
|
||||
struct tty *tp = &hx8357_ttys[0];
|
||||
struct iovec *iov = uio->uio_iov;
|
||||
|
||||
while (iov->iov_len > 0) {
|
||||
ttyinput(*(iov->iov_base), tp);
|
||||
iov->iov_base ++;
|
||||
iov->iov_len --;
|
||||
uio->uio_resid --;
|
||||
uio->uio_offset ++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return ENODEV;
|
||||
}
|
||||
|
||||
int hx8357_ioctl(dev_t dev, register u_int cmd, caddr_t addr, int flag) {
|
||||
int unit = minor(dev);
|
||||
|
||||
if (unit == 0) {
|
||||
struct tty *tp = &hx8357_ttys[unit];
|
||||
int error;
|
||||
|
||||
error = ttioctl(tp, cmd, addr, flag);
|
||||
if (error < 0)
|
||||
error = ENOTTY;
|
||||
return (error);
|
||||
}
|
||||
if (unit == 1) {
|
||||
return EIO;
|
||||
}
|
||||
|
||||
return ENODEV;
|
||||
|
||||
}
|
||||
|
||||
void hx8357_putc(dev_t dev, char c) {
|
||||
writeChar(c);
|
||||
}
|
||||
|
||||
char hx8357_getc(dev_t dev) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hx8357_select (dev_t dev, int rw) {
|
||||
int unit = minor(dev);
|
||||
if (unit == 0) {
|
||||
struct tty *tp = &hx8357_ttys[unit];
|
||||
return (ttyselect (tp, rw));
|
||||
}
|
||||
if (unit == 1) {
|
||||
return EIO;
|
||||
}
|
||||
return ENODEV;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,10 @@
|
||||
# include <machine/usb_function_cdc.h>
|
||||
#endif
|
||||
|
||||
#ifdef HX8357_ENABLED
|
||||
#include "hx8357.h"
|
||||
#endif
|
||||
|
||||
#ifdef POWER_ENABLED
|
||||
extern void power_init();
|
||||
extern void power_off();
|
||||
@@ -344,6 +348,9 @@ startup()
|
||||
#endif
|
||||
#ifdef UARTUSB_ENABLED
|
||||
usbinit();
|
||||
#endif
|
||||
#ifdef HX8357_ENABLED
|
||||
hx8357_init();
|
||||
#endif
|
||||
cninit();
|
||||
|
||||
|
||||
@@ -6,13 +6,13 @@ S = ../../../tools/configsys/../../sys/kernel
|
||||
vpath %.c $(M):$(S)
|
||||
vpath %.S $(M):$(S)
|
||||
|
||||
KERNOBJ += adc.o clock.o cons.o devsw.o exception.o exec_aout.o exec_conf.o exec_elf.o exec_script.o exec_subr.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rd_spirams.o rdisk.o signal.o spi_bus.o startup.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o uart.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o
|
||||
KERNOBJ += adc.o clock.o cons.o devsw.o exception.o exec_aout.o exec_conf.o exec_elf.o exec_script.o exec_subr.o gpio.o hx8357.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o rd_sd.o rd_spirams.o rdisk.o signal.o spi_bus.o startup.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o uart.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o
|
||||
EXTRA_TARGETS =
|
||||
|
||||
DEFS += -DADC_ENABLED=YES
|
||||
DEFS += -DBUS_DIV=1
|
||||
DEFS += -DBUS_KHZ=80000
|
||||
DEFS += -DCONSOLE_DEVICE=tty0
|
||||
DEFS += -DCONSOLE_DEVICE=tft0
|
||||
DEFS += -DCPU_IDIV=2
|
||||
DEFS += -DCPU_KHZ=80000
|
||||
DEFS += -DCPU_MUL=20
|
||||
@@ -46,13 +46,14 @@ DEFS += -DEXEC_AOUT
|
||||
DEFS += -DEXEC_ELF
|
||||
DEFS += -DEXEC_SCRIPT
|
||||
DEFS += -DGPIO_ENABLED=YES
|
||||
DEFS += -DHX8357_ENABLED
|
||||
DEFS += -DKERNEL
|
||||
DEFS += -DPARTITION="spirams0:sa@1500"
|
||||
DEFS += -DPARTITION="spirams0:sa@2040"
|
||||
DEFS += -DPIC32MX7
|
||||
DEFS += -DSD0_CS_PIN=9
|
||||
DEFS += -DSD0_CS_PORT=TRISG
|
||||
DEFS += -DSD0_PORT=2
|
||||
DEFS += -DSPIRAMS_CHIPS=13
|
||||
DEFS += -DSPIRAMS_CHIPS=16
|
||||
DEFS += -DSPIRAMS_CHIPSIZE=128
|
||||
DEFS += -DSPIRAMS_CS0_PIN=0
|
||||
DEFS += -DSPIRAMS_CS0_PORT=TRISA
|
||||
@@ -62,6 +63,12 @@ DEFS += -DSPIRAMS_CS11_PIN=7
|
||||
DEFS += -DSPIRAMS_CS11_PORT=TRISA
|
||||
DEFS += -DSPIRAMS_CS12_PIN=14
|
||||
DEFS += -DSPIRAMS_CS12_PORT=TRISG
|
||||
DEFS += -DSPIRAMS_CS13_PIN=12
|
||||
DEFS += -DSPIRAMS_CS13_PORT=TRISG
|
||||
DEFS += -DSPIRAMS_CS14_PIN=13
|
||||
DEFS += -DSPIRAMS_CS14_PORT=TRISG
|
||||
DEFS += -DSPIRAMS_CS15_PIN=5
|
||||
DEFS += -DSPIRAMS_CS15_PORT=TRISF
|
||||
DEFS += -DSPIRAMS_CS1_PIN=1
|
||||
DEFS += -DSPIRAMS_CS1_PORT=TRISA
|
||||
DEFS += -DSPIRAMS_CS2_PIN=4
|
||||
|
||||
@@ -8,15 +8,16 @@ linker bootloader-max32
|
||||
|
||||
device kernel cpu_khz=80000 bus_khz=80000
|
||||
|
||||
device console device=tty0
|
||||
device console device=tft0
|
||||
device uart1 baud=115200
|
||||
|
||||
device rdisk
|
||||
device sd0 port=2 cs=48
|
||||
device spirams0 port=4 chips=13 cs0=26 cs1=27 cs2=28 cs3=29 cs4=30 cs5=31 cs6=32 cs7=33 cs8=34 cs9=35 cs10=36 cs11=37 cs12=38
|
||||
device spirams0 port=4 chips=16 cs0=26 cs1=27 cs2=28 cs3=29 cs4=30 cs5=31 cs6=32 cs7=33 cs8=34 cs9=35 cs10=36 cs11=37 cs12=38 cs13=39 cs14=40 cs15=51
|
||||
|
||||
option PARTITION=spirams0:sa@1500
|
||||
option PARTITION=spirams0:sa@2040
|
||||
|
||||
device hxtft
|
||||
device gpio
|
||||
device adc
|
||||
device foreignbootloader
|
||||
|
||||
438
sys/pic32/rd_spirams.c
Normal file
438
sys/pic32/rd_spirams.c
Normal file
@@ -0,0 +1,438 @@
|
||||
#include "param.h"
|
||||
#include "systm.h"
|
||||
#include "buf.h"
|
||||
#include "errno.h"
|
||||
#include "dk.h"
|
||||
#include "rdisk.h"
|
||||
#include "spi_bus.h"
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
#define SPIRAM_WREN 0x06
|
||||
#define SPIRAM_WRDI 0x04
|
||||
#define SPIRAM_RDSR 0x05
|
||||
#define SPIRAM_WRSR 0x01
|
||||
#define SPIRAM_READ 0x03
|
||||
#define SPIRAM_WRITE 0x02
|
||||
#define SPIRAM_SLEEP 0xB9
|
||||
#define SPIRAM_WAKE 0xAB
|
||||
|
||||
#ifndef SPIRAMS_MHZ
|
||||
#define SPIRAMS_MHZ 10
|
||||
#endif
|
||||
|
||||
int fd[SPIRAMS_CHIPS];
|
||||
|
||||
int spirams_size(int unit)
|
||||
{
|
||||
return SPIRAMS_CHIPS * SPIRAMS_CHIPSIZE;
|
||||
}
|
||||
|
||||
#define MRBSIZE 1024
|
||||
#define MRBLOG2 10
|
||||
|
||||
unsigned int spir_read_block(unsigned int chip, unsigned int address, unsigned int length, char *data)
|
||||
{
|
||||
register unsigned int cs = 0;
|
||||
|
||||
switch(chip)
|
||||
{
|
||||
case 0:
|
||||
#ifdef SPIRAMS_LED0_PORT
|
||||
TRIS_CLR(SPIRAMS_LED0_PORT) = 1<<SPIRAMS_LED0_PIN;
|
||||
LAT_SET(SPIRAMS_LED0_PORT) = 1<<SPIRAMS_LED0_PIN;
|
||||
#endif
|
||||
break;
|
||||
case 1:
|
||||
#ifdef SPIRAMS_LED1_PORT
|
||||
TRIS_CLR(SPIRAMS_LED1_PORT) = 1<<SPIRAMS_LED1_PIN;
|
||||
LAT_SET(SPIRAMS_LED1_PORT) = 1<<SPIRAMS_LED1_PIN;
|
||||
#endif
|
||||
break;
|
||||
case 2:
|
||||
#ifdef SPIRAMS_LED2_PORT
|
||||
TRIS_CLR(SPIRAMS_LED2_PORT) = 1<<SPIRAMS_LED2_PIN;
|
||||
LAT_SET(SPIRAMS_LED2_PORT) = 1<<SPIRAMS_LED2_PIN;
|
||||
#endif
|
||||
break;
|
||||
case 3:
|
||||
#ifdef SPIRAMS_LED3_PORT
|
||||
TRIS_CLR(SPIRAMS_LED3_PORT) = 1<<SPIRAMS_LED3_PIN;
|
||||
LAT_SET(SPIRAMS_LED3_PORT) = 1<<SPIRAMS_LED3_PIN;
|
||||
#endif
|
||||
break;
|
||||
case 4:
|
||||
#ifdef SPIRAMS_LED4_PORT
|
||||
TRIS_CLR(SPIRAMS_LED4_PORT) = 1<<SPIRAMS_LED4_PIN;
|
||||
LAT_SET(SPIRAMS_LED4_PORT) = 1<<SPIRAMS_LED4_PIN;
|
||||
#endif
|
||||
break;
|
||||
case 5:
|
||||
#ifdef SPIRAMS_LED5_PORT
|
||||
TRIS_CLR(SPIRAMS_LED5_PORT) = 1<<SPIRAMS_LED5_PIN;
|
||||
LAT_SET(SPIRAMS_LED5_PORT) = 1<<SPIRAMS_LED5_PIN;
|
||||
#endif
|
||||
break;
|
||||
case 6:
|
||||
#ifdef SPIRAMS_LED6_PORT
|
||||
TRIS_CLR(SPIRAMS_LED6_PORT) = 1<<SPIRAMS_LED6_PIN;
|
||||
LAT_SET(SPIRAMS_LED6_PORT) = 1<<SPIRAMS_LED6_PIN;
|
||||
#endif
|
||||
break;
|
||||
case 7:
|
||||
#ifdef SPIRAMS_LED7_PORT
|
||||
TRIS_CLR(SPIRAMS_LED7_PORT) = 1<<SPIRAMS_LED7_PIN;
|
||||
LAT_SET(SPIRAMS_LED7_PORT) = 1<<SPIRAMS_LED7_PIN;
|
||||
#endif
|
||||
break;
|
||||
case 8:
|
||||
#ifdef SPIRAMS_LED8_PORT
|
||||
TRIS_CLR(SPIRAMS_LED8_PORT) = 1<<SPIRAMS_LED8_PIN;
|
||||
LAT_SET(SPIRAMS_LED8_PORT) = 1<<SPIRAMS_LED8_PIN;
|
||||
#endif
|
||||
break;
|
||||
case 9:
|
||||
#ifdef SPIRAMS_LED9_PORT
|
||||
TRIS_CLR(SPIRAMS_LED9_PORT) = 1<<SPIRAMS_LED9_PIN;
|
||||
LAT_SET(SPIRAMS_LED9_PORT) = 1<<SPIRAMS_LED9_PIN;
|
||||
#endif
|
||||
break;
|
||||
case 10:
|
||||
#ifdef SPIRAMS_LED10_PORT
|
||||
TRIS_CLR(SPIRAMS_LED10_PORT) = 1<<SPIRAMS_LED10_PIN;
|
||||
LAT_SET(SPIRAMS_LED10_PORT) = 1<<SPIRAMS_LED10_PIN;
|
||||
#endif
|
||||
break;
|
||||
case 11:
|
||||
#ifdef SPIRAMS_LED11_PORT
|
||||
TRIS_CLR(SPIRAMS_LED11_PORT) = 1<<SPIRAMS_LED11_PIN;
|
||||
LAT_SET(SPIRAMS_LED11_PORT) = 1<<SPIRAMS_LED11_PIN;
|
||||
#endif
|
||||
break;
|
||||
case 12:
|
||||
#ifdef SPIRAMS_LED12_PORT
|
||||
TRIS_CLR(SPIRAMS_LED12_PORT) = 1<<SPIRAMS_LED12_PIN;
|
||||
LAT_SET(SPIRAMS_LED12_PORT) = 1<<SPIRAMS_LED12_PIN;
|
||||
#endif
|
||||
break;
|
||||
case 13:
|
||||
#ifdef SPIRAMS_LED13_PORT
|
||||
TRIS_CLR(SPIRAMS_LED13_PORT) = 1<<SPIRAMS_LED13_PIN;
|
||||
LAT_SET(SPIRAMS_LED13_PORT) = 1<<SPIRAMS_LED13_PIN;
|
||||
#endif
|
||||
break;
|
||||
case 14:
|
||||
#ifdef SPIRAMS_LED14_PORT
|
||||
TRIS_CLR(SPIRAMS_LED14_PORT) = 1<<SPIRAMS_LED14_PIN;
|
||||
LAT_SET(SPIRAMS_LED14_PORT) = 1<<SPIRAMS_LED14_PIN;
|
||||
#endif
|
||||
break;
|
||||
case 15:
|
||||
#ifdef SPIRAMS_LED15_PORT
|
||||
TRIS_CLR(SPIRAMS_LED15_PORT) = 1<<SPIRAMS_LED15_PIN;
|
||||
LAT_SET(SPIRAMS_LED15_PORT) = 1<<SPIRAMS_LED15_PIN;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
spi_select(fd[chip]);
|
||||
spi_transfer(fd[chip], SPIRAM_READ);
|
||||
spi_transfer(fd[chip], address>>16);
|
||||
spi_transfer(fd[chip], address>>8);
|
||||
spi_transfer(fd[chip], address);
|
||||
|
||||
// If the length is a multiple of 32 bits, then do a 32 bit transfer
|
||||
/*
|
||||
if((length & 0x03) == 0)
|
||||
spi_bulk_read_32(fd[chip],length,data);
|
||||
else if((length & 0x01) == 0)
|
||||
spi_bulk_read_16(fd[chip],length,data);
|
||||
else
|
||||
*/
|
||||
spi_bulk_read(fd[chip],length,(unsigned char *)data);
|
||||
|
||||
spi_deselect(fd[chip]);
|
||||
|
||||
switch(chip)
|
||||
{
|
||||
case 0:
|
||||
#ifdef SPIRAMS_LED0_PORT
|
||||
LAT_CLR(SPIRAMS_LED0_PORT) = 1<<SPIRAMS_LED0_PIN;
|
||||
#endif
|
||||
break;
|
||||
case 1:
|
||||
#ifdef SPIRAMS_LED1_PORT
|
||||
LAT_CLR(SPIRAMS_LED1_PORT) = 1<<SPIRAMS_LED1_PIN;
|
||||
#endif
|
||||
break;
|
||||
case 2:
|
||||
#ifdef SPIRAMS_LED2_PORT
|
||||
LAT_CLR(SPIRAMS_LED2_PORT) = 1<<SPIRAMS_LED2_PIN;
|
||||
#endif
|
||||
break;
|
||||
case 3:
|
||||
#ifdef SPIRAMS_LED3_PORT
|
||||
LAT_CLR(SPIRAMS_LED3_PORT) = 1<<SPIRAMS_LED3_PIN;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
return cs;
|
||||
}
|
||||
|
||||
int spirams_read(int unit, unsigned int offset, char *data, unsigned int bcount)
|
||||
{
|
||||
register unsigned int chip;
|
||||
register unsigned int toread;
|
||||
register unsigned int address;
|
||||
register unsigned int pass = 0;
|
||||
|
||||
while(bcount > 0)
|
||||
{
|
||||
pass++;
|
||||
toread = bcount;
|
||||
if(toread > MRBSIZE)
|
||||
toread = MRBSIZE;
|
||||
|
||||
chip = offset / SPIRAMS_CHIPSIZE;
|
||||
|
||||
address = (offset<<10) - (chip * (SPIRAMS_CHIPSIZE*1024));
|
||||
|
||||
|
||||
if(chip>=SPIRAMS_CHIPS)
|
||||
{
|
||||
printf("!!!EIO\n");
|
||||
return EIO;
|
||||
}
|
||||
spir_read_block(chip, address, toread, data);
|
||||
bcount -= toread;
|
||||
offset += (toread>>MRBLOG2);
|
||||
data += toread;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned int spir_write_block(unsigned int chip, unsigned int address, unsigned int length, char *data)
|
||||
{
|
||||
register unsigned int cs = 0;
|
||||
char blank __attribute__((unused));
|
||||
|
||||
switch(chip)
|
||||
{
|
||||
case 0:
|
||||
#ifdef SPIRAMS_LED0_PORT
|
||||
TRIS_CLR(SPIRAMS_LED0_PORT) = 1<<SPIRAMS_LED0_PIN;
|
||||
LAT_SET(SPIRAMS_LED0_PORT) = 1<<SPIRAMS_LED0_PIN;
|
||||
#endif
|
||||
break;
|
||||
case 1:
|
||||
#ifdef SPIRAMS_LED1_PORT
|
||||
TRIS_CLR(SPIRAMS_LED1_PORT) = 1<<SPIRAMS_LED1_PIN;
|
||||
LAT_SET(SPIRAMS_LED1_PORT) = 1<<SPIRAMS_LED1_PIN;
|
||||
#endif
|
||||
break;
|
||||
case 2:
|
||||
#ifdef SPIRAMS_LED2_PORT
|
||||
TRIS_CLR(SPIRAMS_LED2_PORT) = 1<<SPIRAMS_LED2_PIN;
|
||||
LAT_SET(SPIRAMS_LED2_PORT) = 1<<SPIRAMS_LED2_PIN;
|
||||
#endif
|
||||
break;
|
||||
case 3:
|
||||
#ifdef SPIRAMS_LED3_PORT
|
||||
TRIS_CLR(SPIRAMS_LED3_PORT) = 1<<SPIRAMS_LED3_PIN;
|
||||
LAT_SET(SPIRAMS_LED3_PORT) = 1<<SPIRAMS_LED3_PIN;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
spi_select(fd[chip]);
|
||||
spi_transfer(fd[chip], SPIRAM_WRITE);
|
||||
spi_transfer(fd[chip], address>>16);
|
||||
spi_transfer(fd[chip], address>>8);
|
||||
spi_transfer(fd[chip], address);
|
||||
|
||||
/*
|
||||
if((length & 0x03) == 0)
|
||||
spi_bulk_write_32(fd[chip],length,data);
|
||||
else if((length & 0x01) == 0)
|
||||
spi_bulk_write_16(fd[chip],length,data);
|
||||
else
|
||||
*/
|
||||
spi_bulk_write(fd[chip],length,(unsigned char *)data);
|
||||
|
||||
spi_deselect(fd[chip]);
|
||||
|
||||
switch(chip)
|
||||
{
|
||||
case 0:
|
||||
#ifdef SPIRAMS_LED0_PORT
|
||||
LAT_CLR(SPIRAMS_LED0_PORT) = 1<<SPIRAMS_LED0_PIN;
|
||||
#endif
|
||||
break;
|
||||
case 1:
|
||||
#ifdef SPIRAMS_LED1_PORT
|
||||
LAT_CLR(SPIRAMS_LED1_PORT) = 1<<SPIRAMS_LED1_PIN;
|
||||
#endif
|
||||
break;
|
||||
case 2:
|
||||
#ifdef SPIRAMS_LED2_PORT
|
||||
LAT_CLR(SPIRAMS_LED2_PORT) = 1<<SPIRAMS_LED2_PIN;
|
||||
#endif
|
||||
break;
|
||||
case 3:
|
||||
#ifdef SPIRAMS_LED3_PORT
|
||||
LAT_CLR(SPIRAMS_LED3_PORT) = 1<<SPIRAMS_LED3_PIN;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
return cs;
|
||||
}
|
||||
|
||||
int spirams_write (int unit, unsigned int offset, char *data, unsigned bcount)
|
||||
{
|
||||
register unsigned int chip;
|
||||
register unsigned int address;
|
||||
register unsigned int towrite;
|
||||
register unsigned int pass = 0;
|
||||
|
||||
while(bcount > 0)
|
||||
{
|
||||
pass++;
|
||||
towrite = bcount;
|
||||
if(towrite > MRBSIZE)
|
||||
towrite = MRBSIZE;
|
||||
|
||||
chip = offset / SPIRAMS_CHIPSIZE;
|
||||
address = (offset<<10) - (chip * (SPIRAMS_CHIPSIZE*MRBSIZE));
|
||||
|
||||
if(chip>=SPIRAMS_CHIPS)
|
||||
{
|
||||
printf("!!!EIO\n");
|
||||
return EIO;
|
||||
}
|
||||
|
||||
spir_write_block(chip, address, towrite, data);
|
||||
bcount -= towrite;
|
||||
offset += (towrite>>MRBLOG2);
|
||||
data += towrite;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void spirams_preinit (int unit)
|
||||
{
|
||||
struct buf *bp;
|
||||
|
||||
if (unit >= 1)
|
||||
return;
|
||||
|
||||
/* Initialize hardware. */
|
||||
|
||||
|
||||
fd[0] = spi_open(SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS0_PORT,SPIRAMS_CS0_PIN);
|
||||
if(fd[0]==-1) return;
|
||||
|
||||
spi_brg(fd[0],SPIRAMS_MHZ * 1000);
|
||||
spi_set(fd[0],PIC32_SPICON_CKE);
|
||||
|
||||
#ifdef SPIRAMS_CS1_PORT
|
||||
fd[1] = spi_open(SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS1_PORT,SPIRAMS_CS1_PIN);
|
||||
|
||||
spi_brg(fd[1],SPIRAMS_MHZ * 1000);
|
||||
spi_set(fd[1],PIC32_SPICON_CKE);
|
||||
#endif
|
||||
#ifdef SPIRAMS_CS2_PORT
|
||||
fd[2] = spi_open(SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS2_PORT,SPIRAMS_CS2_PIN);
|
||||
|
||||
spi_brg(fd[2],SPIRAMS_MHZ * 1000);
|
||||
spi_set(fd[2],PIC32_SPICON_CKE);
|
||||
#endif
|
||||
#ifdef SPIRAMS_CS3_PORT
|
||||
fd[3] = spi_open(SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS3_PORT,SPIRAMS_CS3_PIN);
|
||||
|
||||
spi_brg(fd[3],SPIRAMS_MHZ * 1000);
|
||||
spi_set(fd[3],PIC32_SPICON_CKE);
|
||||
#endif
|
||||
#ifdef SPIRAMS_CS4_PORT
|
||||
fd[4] = spi_open(SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS4_PORT,SPIRAMS_CS4_PIN);
|
||||
|
||||
spi_brg(fd[4],SPIRAMS_MHZ * 1000);
|
||||
spi_set(fd[4],PIC32_SPICON_CKE);
|
||||
#endif
|
||||
#ifdef SPIRAMS_CS5_PORT
|
||||
fd[5] = spi_open(SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS5_PORT,SPIRAMS_CS5_PIN);
|
||||
|
||||
spi_brg(fd[5],SPIRAMS_MHZ * 1000);
|
||||
spi_set(fd[5],PIC32_SPICON_CKE);
|
||||
#endif
|
||||
#ifdef SPIRAMS_CS6_PORT
|
||||
fd[6] = spi_open(SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS6_PORT,SPIRAMS_CS6_PIN);
|
||||
|
||||
spi_brg(fd[6],SPIRAMS_MHZ * 1000);
|
||||
spi_set(fd[6],PIC32_SPICON_CKE);
|
||||
#endif
|
||||
#ifdef SPIRAMS_CS7_PORT
|
||||
fd[7] = spi_open(SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS7_PORT,SPIRAMS_CS7_PIN);
|
||||
|
||||
spi_brg(fd[7],SPIRAMS_MHZ * 1000);
|
||||
spi_set(fd[7],PIC32_SPICON_CKE);
|
||||
#endif
|
||||
#ifdef SPIRAMS_CS8_PORT
|
||||
fd[8] = spi_open(SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS8_PORT,SPIRAMS_CS8_PIN);
|
||||
|
||||
spi_brg(fd[8],SPIRAMS_MHZ * 1000);
|
||||
spi_set(fd[8],PIC32_SPICON_CKE);
|
||||
#endif
|
||||
#ifdef SPIRAMS_CS9_PORT
|
||||
fd[9] = spi_open(SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS9_PORT,SPIRAMS_CS9_PIN);
|
||||
|
||||
spi_brg(fd[9],SPIRAMS_MHZ * 1000);
|
||||
spi_set(fd[9],PIC32_SPICON_CKE);
|
||||
#endif
|
||||
#ifdef SPIRAMS_CS10_PORT
|
||||
fd[10] = spi_open(SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS10_PORT,SPIRAMS_CS10_PIN);
|
||||
|
||||
spi_brg(fd[10],SPIRAMS_MHZ * 1000);
|
||||
spi_set(fd[10],PIC32_SPICON_CKE);
|
||||
#endif
|
||||
#ifdef SPIRAMS_CS11_PORT
|
||||
fd[11] = spi_open(SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS11_PORT,SPIRAMS_CS11_PIN);
|
||||
|
||||
spi_brg(fd[11],SPIRAMS_MHZ * 1000);
|
||||
spi_set(fd[11],PIC32_SPICON_CKE);
|
||||
#endif
|
||||
#ifdef SPIRAMS_CS12_PORT
|
||||
fd[12] = spi_open(SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS12_PORT,SPIRAMS_CS12_PIN);
|
||||
|
||||
spi_brg(fd[12],SPIRAMS_MHZ * 1000);
|
||||
spi_set(fd[12],PIC32_SPICON_CKE);
|
||||
#endif
|
||||
#ifdef SPIRAMS_CS13_PORT
|
||||
fd[13] = spi_open(SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS13_PORT,SPIRAMS_CS13_PIN);
|
||||
|
||||
spi_brg(fd[13],SPIRAMS_MHZ * 1000);
|
||||
spi_set(fd[13],PIC32_SPICON_CKE);
|
||||
#endif
|
||||
#ifdef SPIRAMS_CS14_PORT
|
||||
fd[14] = spi_open(SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS14_PORT,SPIRAMS_CS14_PIN);
|
||||
|
||||
spi_brg(fd[14],SPIRAMS_MHZ * 1000);
|
||||
spi_set(fd[14],PIC32_SPICON_CKE);
|
||||
#endif
|
||||
#ifdef SPIRAMS_CS15_PORT
|
||||
fd[15] = spi_open(SPIRAMS_PORT,(unsigned int *)&SPIRAMS_CS15_PORT,SPIRAMS_CS15_PIN);
|
||||
|
||||
spi_brg(fd[15],SPIRAMS_MHZ * 1000);
|
||||
spi_set(fd[15],PIC32_SPICON_CKE);
|
||||
#endif
|
||||
|
||||
printf("spirams0: port %d %s, size %dKB, speed %d Mbit/sec\n",
|
||||
SPIRAMS_PORT, spi_name(fd[0]),SPIRAMS_CHIPS * SPIRAMS_CHIPSIZE,
|
||||
spi_get_brg(fd[0]) / 1000);
|
||||
bp = prepartition_device("spirams0");
|
||||
if(bp)
|
||||
{
|
||||
spirams_write (0, 0, bp->b_addr, 512);
|
||||
brelse(bp);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user