diff options
Diffstat (limited to 'libraries/MultiLCD/hardware/pic32')
-rw-r--r-- | libraries/MultiLCD/hardware/pic32/HW_PIC32.h | 7 | ||||
-rw-r--r-- | libraries/MultiLCD/hardware/pic32/HW_PIC32MX320F128H.h | 174 | ||||
-rw-r--r-- | libraries/MultiLCD/hardware/pic32/HW_PIC32MX340F512H.h | 174 | ||||
-rw-r--r-- | libraries/MultiLCD/hardware/pic32/HW_PIC32MX795F512L.h | 188 | ||||
-rw-r--r-- | libraries/MultiLCD/hardware/pic32/HW_PIC32_defines.h | 26 |
5 files changed, 569 insertions, 0 deletions
diff --git a/libraries/MultiLCD/hardware/pic32/HW_PIC32.h b/libraries/MultiLCD/hardware/pic32/HW_PIC32.h new file mode 100644 index 0000000..c71a5ff --- /dev/null +++ b/libraries/MultiLCD/hardware/pic32/HW_PIC32.h @@ -0,0 +1,7 @@ +void UTFT::_convert_float(char *buf, double num, int width, byte prec) +{ + char format[10]; + + sprintf(format, "%%%i.%if", width, prec); + sprintf(buf, format, num); +} diff --git a/libraries/MultiLCD/hardware/pic32/HW_PIC32MX320F128H.h b/libraries/MultiLCD/hardware/pic32/HW_PIC32MX320F128H.h new file mode 100644 index 0000000..7ea4466 --- /dev/null +++ b/libraries/MultiLCD/hardware/pic32/HW_PIC32MX320F128H.h @@ -0,0 +1,174 @@ +// *** Hardwarespecific functions *** +void UTFT::_hw_special_init() +{ +} + +void UTFT::LCD_Writ_Bus(char VH,char VL, byte mode) +{ + switch (mode) + { + case 1: + if (display_serial_mode==SERIAL_4PIN) + { + if (VH==1) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + } + else + { + if (VH==1) + sbi(P_RS, B_RS); + else + cbi(P_RS, B_RS); + } + + if (VL & 0x80) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + if (VL & 0x40) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + if (VL & 0x20) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + if (VL & 0x10) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + if (VL & 0x08) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + if (VL & 0x04) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + if (VL & 0x02) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + if (VL & 0x01) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + break; + case 8: + LATECLR = 0xFF; + LATESET = VH; + *P_WR &= ~B_WR; + *P_WR |= B_WR; + LATECLR = 0xFF; + LATESET = VL; + *P_WR &= ~B_WR; + *P_WR |= B_WR; + break; + case 16: + LATDCLR = 0xFF; + LATDSET = VL & 0xFF; + LATECLR = 0xFF; + LATESET = VH & 0xFF; + *P_WR &= ~B_WR; + *P_WR |= B_WR; + break; + case LATCHED_16: + asm("nop"); // Mode is unsupported + break; + } +} + +void UTFT::_set_direction_registers(byte mode) +{ + if (mode!=LATCHED_16) + { + TRISE=0; + if (mode==16) + TRISD=0; + } + else + { + asm("nop"); // Mode is unsupported + } +} + +void UTFT::_fast_fill_16(int ch, int cl, long pix) +{ + long blocks; + + LATDCLR = 0xFF; + LATDSET = cl & 0xFF; + LATECLR = 0xFF; + LATESET = ch & 0xFF; + + blocks = pix/16; + for (int i=0; i<blocks; i++) + { + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + } + if ((pix % 16) != 0) + for (int i=0; i<(pix % 16)+1; i++) + { + *P_WR &= ~B_WR; *P_WR |= B_WR; + } +} + +void UTFT::_fast_fill_8(int ch, long pix) +{ + long blocks; + + LATECLR = 0xFF; + LATESET = ch; + + blocks = pix/16; + for (int i=0; i<blocks; i++) + { + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + } + if ((pix % 16) != 0) + for (int i=0; i<(pix % 16)+1; i++) + { + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + } +} diff --git a/libraries/MultiLCD/hardware/pic32/HW_PIC32MX340F512H.h b/libraries/MultiLCD/hardware/pic32/HW_PIC32MX340F512H.h new file mode 100644 index 0000000..7ea4466 --- /dev/null +++ b/libraries/MultiLCD/hardware/pic32/HW_PIC32MX340F512H.h @@ -0,0 +1,174 @@ +// *** Hardwarespecific functions *** +void UTFT::_hw_special_init() +{ +} + +void UTFT::LCD_Writ_Bus(char VH,char VL, byte mode) +{ + switch (mode) + { + case 1: + if (display_serial_mode==SERIAL_4PIN) + { + if (VH==1) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + } + else + { + if (VH==1) + sbi(P_RS, B_RS); + else + cbi(P_RS, B_RS); + } + + if (VL & 0x80) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + if (VL & 0x40) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + if (VL & 0x20) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + if (VL & 0x10) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + if (VL & 0x08) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + if (VL & 0x04) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + if (VL & 0x02) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + if (VL & 0x01) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + break; + case 8: + LATECLR = 0xFF; + LATESET = VH; + *P_WR &= ~B_WR; + *P_WR |= B_WR; + LATECLR = 0xFF; + LATESET = VL; + *P_WR &= ~B_WR; + *P_WR |= B_WR; + break; + case 16: + LATDCLR = 0xFF; + LATDSET = VL & 0xFF; + LATECLR = 0xFF; + LATESET = VH & 0xFF; + *P_WR &= ~B_WR; + *P_WR |= B_WR; + break; + case LATCHED_16: + asm("nop"); // Mode is unsupported + break; + } +} + +void UTFT::_set_direction_registers(byte mode) +{ + if (mode!=LATCHED_16) + { + TRISE=0; + if (mode==16) + TRISD=0; + } + else + { + asm("nop"); // Mode is unsupported + } +} + +void UTFT::_fast_fill_16(int ch, int cl, long pix) +{ + long blocks; + + LATDCLR = 0xFF; + LATDSET = cl & 0xFF; + LATECLR = 0xFF; + LATESET = ch & 0xFF; + + blocks = pix/16; + for (int i=0; i<blocks; i++) + { + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + } + if ((pix % 16) != 0) + for (int i=0; i<(pix % 16)+1; i++) + { + *P_WR &= ~B_WR; *P_WR |= B_WR; + } +} + +void UTFT::_fast_fill_8(int ch, long pix) +{ + long blocks; + + LATECLR = 0xFF; + LATESET = ch; + + blocks = pix/16; + for (int i=0; i<blocks; i++) + { + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + } + if ((pix % 16) != 0) + for (int i=0; i<(pix % 16)+1; i++) + { + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + } +} diff --git a/libraries/MultiLCD/hardware/pic32/HW_PIC32MX795F512L.h b/libraries/MultiLCD/hardware/pic32/HW_PIC32MX795F512L.h new file mode 100644 index 0000000..15822f1 --- /dev/null +++ b/libraries/MultiLCD/hardware/pic32/HW_PIC32MX795F512L.h @@ -0,0 +1,188 @@ +// *** Hardwarespecific functions *** +void UTFT::_hw_special_init() +{ +} + +void UTFT::LCD_Writ_Bus(char VH,char VL, byte mode) +{ + switch (mode) + { + case 1: + if (display_serial_mode==SERIAL_4PIN) + { + if (VH==1) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + } + else + { + if (VH==1) + sbi(P_RS, B_RS); + else + cbi(P_RS, B_RS); + } + + if (VL & 0x80) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + if (VL & 0x40) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + if (VL & 0x20) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + if (VL & 0x10) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + if (VL & 0x08) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + if (VL & 0x04) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + if (VL & 0x02) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + if (VL & 0x01) + sbi(P_SDA, B_SDA); + else + cbi(P_SDA, B_SDA); + pulse_low(P_SCL, B_SCL); + break; + case 8: + LATECLR = 0xFF; + LATESET = VH; + *P_WR &= ~B_WR; + *P_WR |= B_WR; + LATECLR = 0xFF; + LATESET = VL; + *P_WR &= ~B_WR; + *P_WR |= B_WR; + break; + case 16: +#ifdef AQUALED_SHIELD + LATACLR = 0xFF; + LATASET = VL & 0xFF; +#else + LATDCLR = 0xFF; + LATDSET = VL & 0xFF; +#endif + LATECLR = 0xFF; + LATESET = VH & 0xFF; + *P_WR &= ~B_WR; + *P_WR |= B_WR; + break; + case LATCHED_16: + asm("nop"); // Mode is unsupported + break; + } +} + +void UTFT::_set_direction_registers(byte mode) +{ + if (mode!=LATCHED_16) + { + TRISE=0; + if (mode==16) +#ifdef AQUALED_SHIELD + TRISA=0; +#else + TRISD=0; +#endif + } + else + { + asm("nop"); // Mode is unsupported + } +} + +void UTFT::_fast_fill_16(int ch, int cl, long pix) +{ + long blocks; + +#ifdef AQUALED_SHIELD + LATACLR = 0xFF; + LATASET = cl & 0xFF; +#else + LATDCLR = 0xFF; + LATDSET = cl & 0xFF; +#endif + LATECLR = 0xFF; + LATESET = ch & 0xFF; + + blocks = pix/16; + for (int i=0; i<blocks; i++) + { + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; + } + if ((pix % 16) != 0) + for (int i=0; i<(pix % 16)+1; i++) + { + *P_WR &= ~B_WR; *P_WR |= B_WR; + } +} + +void UTFT::_fast_fill_8(int ch, long pix) +{ + long blocks; + + LATECLR = 0xFF; + LATESET = ch; + + blocks = pix/16; + for (int i=0; i<blocks; i++) + { + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + } + if ((pix % 16) != 0) + for (int i=0; i<(pix % 16)+1; i++) + { + *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR; + } +} diff --git a/libraries/MultiLCD/hardware/pic32/HW_PIC32_defines.h b/libraries/MultiLCD/hardware/pic32/HW_PIC32_defines.h new file mode 100644 index 0000000..4b83daa --- /dev/null +++ b/libraries/MultiLCD/hardware/pic32/HW_PIC32_defines.h @@ -0,0 +1,26 @@ +// AquaLEDSource All in One Super Screw Shield +// ------------------------------------------- +// Uncomment the following line if you are using this shield +//#define AQUALED_SHIELD 1 +// +// For this shield: RS=82, WR=83, CS=84, RST=85 (Standard for chipKit Max32) +//************************************************************************** + +// *** Hardwarespecific defines *** +#define cbi(reg, bitmask) (*(reg + 1)) = bitmask +#define sbi(reg, bitmask) (*(reg + 2)) = bitmask +#define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask); +#define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask); + +#define cport(port, data) port &= data +#define sport(port, data) port |= data + +#define swap(type, i, j) {type t = i; i = j; j = t;} + +#define fontbyte(x) cfont.font[x] + +#define PROGMEM +#define regtype volatile uint32_t +#define regsize uint16_t +#define bitmapdatatype unsigned short* + |