Frank Duignan
/
NRF52832_ili9341
Basic driver working
Diff: main.cpp
- Revision:
- 80:ff42f77928ad
- Parent:
- 79:a022f7789a49
- Child:
- 81:7087ba9d18bb
diff -r a022f7789a49 -r ff42f77928ad main.cpp --- a/main.cpp Mon Feb 01 14:22:38 2021 +0000 +++ b/main.cpp Wed Feb 03 11:30:30 2021 +0000 @@ -1,33 +1,8 @@ -/* SDT-example-blinky - * - * Copyright (c) 2018 Sigma Delta Technologies Inc. - * - * MIT License - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. +/* ILI9341 interface for the NRF52832 */ #include "mbed.h" - +#include "display.h" /* Serial */ #define BAUDRATE 9600 Serial g_Serial_pc(P0_18, P0_14, BAUDRATE); @@ -35,23 +10,67 @@ /* DigitalOut */ #define LED_ON 0 #define LED_OFF 1 -//DigitalOut g_DO_LedRed(LED_RED, LED_OFF); -//DigitalOut g_DO_LedGreen(LED_GREEN, LED_OFF); -//DigitalOut g_DO_LedBlue(LED_BLUE, LED_OFF); + DigitalOut g_DO_LedBlue(A5, LED_OFF); -//mosi,miso,clk,ss -SPI spi(P0_25,P0_26,P0_27,P0_28); -DigitalOut Rst(P0_21); -DigitalOut DC(P0_20); +Display display; + +uint32_t prbs() +{ + // This is an unverified 31 bit PRBS generator + // It should be maximum length but this has not been verified + static uint32_t shift_register=0xaa551199; + unsigned long new_bit=0; + static int busy=0; // need to prevent re-entrancy here + if (!busy) + { + busy=1; + new_bit= ((shift_register & (1<<27))>>27) ^ ((shift_register & (1<<30))>>30); + new_bit= ~new_bit; + new_bit = new_bit & 1; + shift_register=shift_register << 1; + shift_register=shift_register | (new_bit); + busy=0; + } + return shift_register & 0x7ffffff; // return 31 LSB's +} +uint32_t random(uint32_t lower,uint32_t upper) +{ + return (prbs()%(upper-lower))+lower; +} int main(void) { - spi.format(8, 3); - spi.frequency(1000000); + + int Count; + display.begin(); while(true) { - //g_Serial_pc.printf("LED Toggle\r\n"); - spi.write(0xa5); + g_Serial_pc.printf("LED Toggle\r\n"); g_DO_LedBlue = !g_DO_LedBlue; - wait(0.1); // 1sec + + for (Count = 0; Count < 200; Count++) + { + display.drawRectangle(random(0,240),random(0,320),random(0,240),random(0,320),random(0,0xffff)); + } + display.fillRectangle(0,0,240,320,0); + for (Count = 0; Count < 200; Count++) + { + + display.fillRectangle(random(0,240),random(0,320),random(0,240),random(0,320),random(0,0xffff)); + + } + display.fillRectangle(0,0,240,320,0); + for (Count = 0; Count < 200; Count++) + { + display.drawCircle(random(0,240),random(0,240),random(0,320),random(0,0xffff)); + + } + display.fillRectangle(0,0,240,320,0); + for (Count = 0; Count < 50; Count++) + { + display.fillCircle(random(0,240),random(0,320),random(0,120),random(0,0xffff)); + + } + display.fillRectangle(0,0,240,320,0); + } return 0;