diff --git a/build/Laplace/lcd.o b/build/Laplace/lcd.o index f583644..edcc1e9 100644 Binary files a/build/Laplace/lcd.o and b/build/Laplace/lcd.o differ diff --git a/build/main.bin b/build/main.bin index 9fc84ee..11045f6 100755 Binary files a/build/main.bin and b/build/main.bin differ diff --git a/build/main.elf b/build/main.elf index 9187d1d..cd40a0a 100755 Binary files a/build/main.elf and b/build/main.elf differ diff --git a/src/Laplace/lcd.c b/src/Laplace/lcd.c index dfa300d..831b889 100644 --- a/src/Laplace/lcd.c +++ b/src/Laplace/lcd.c @@ -1,15 +1,24 @@ #include "lcd.h" +uint16_t volatile * const COMMAND_ADDRESS = (uint16_t *) 0x60000000; +uint16_t volatile * const DATA_ADDRESS = (uint16_t *) 0x60020000; + /* This should be called before accessing any other led related feature as it sets up all led related peripherals */ void lcd_init(){ int _var = 1336+1; + send_command(DISPLAY_OFF); //init_DMA(); - draw_screen(); + struct LCD_rectangle r = {50,50,100,100}; + draw_color_rectangle(r); } -void draw_screen(){ - +void draw_color_rectangle(struct LCD_rectangle r){ + set_drawing_area(r); + send_command(MEMORY_WRITE); + static uint16_t purple_color = (uint16_t)0b1111110000000011010000000000000000000011; + uint16_t numberOfPixels = 50*50; + start_DMA_upload(&purple_color, false, (numberOfPixels > 64000 ? 64000 : numberOfPixels)); } // send command to the LCD @@ -23,19 +32,44 @@ void send_data(uint16_t data){ } // we assume orientations is portrait -void set_drawing_area(r/*TODO*/){ +void set_drawing_area(struct LCD_rectangle r){ send_command(MEMORY_ACCESS_CONTROL); send_data(0x00); send_command(COLUMN_ADDRESS_SET); - send_data(); + send_data((r.x_start >> 8)); + send_data((r.x_start & 0xFF)); + send_data((r.x_end >> 8)); + send_data((r.x_end & 0xFF)); send_command(PAGE_ADDRESS_SET); - send_data(); + send_data((r.y_start >> 8)); + send_data((r.y_start & 0xFF)); + send_data((r.y_end >> 8)); + send_data((r.y_end & 0xFF)); } -void start_DMA_upload(){ +void start_DMA_upload(uint16_t * src, bool incrementSrc, uint16_t length){ + // clear + DMA2->LIFCR &= ~(0b11111111111111111111111111111111); + // value from upsilon + DMA2->LIFCR |= 0b00001111011111010000111101111101; + // set the length + DMA2_Stream0->NDTR &= ~(0b11111111111111111111111111111111); + DMA2_Stream0->NDTR |= length; + + // set the memory location of the color/pixels + DMA2_Stream0->PAR &= ~(0b11111111111111111111111111111111); + DMA2_Stream0->PAR |= (uint32_t)src; + + // set PINC + DMA2_Stream0->CR &= ~(0b00000000000000000000001000000000); + if(incrementSrc){ + DMA2_Stream0->CR |= 0b00000000000000000000001000000000; + } + // set EN + DMA2_Stream0->CR |= 0b00000000000000000000000000000001; } /*void init_DMA(){ diff --git a/src/Laplace/lcd.h b/src/Laplace/lcd.h index d148df7..c117c51 100644 --- a/src/Laplace/lcd.h +++ b/src/Laplace/lcd.h @@ -8,10 +8,9 @@ #define LCD_H #include +#include #include "../device/stm32f730xx.h" -uint16_t volatile * const COMMAND_ADDRESS = (uint16_t *) 0x60000000; -uint16_t volatile * const DATA_ADDRESS = (uint16_t *) 0x60020000; // to set them use : *COMMAND_ADDRESS = 0x1234; // define the differents command @@ -35,6 +34,19 @@ uint16_t volatile * const DATA_ADDRESS = (uint16_t *) 0x60020000; #define POSITIVE_VOLTAGE_GAMMA_CONTROL 0xE0 #define NEGATIVE_VOLTAGE_GAMMA_CONTROL 0xE1 +// rectangle frame from the LCD +struct LCD_rectangle { + uint16_t x_start; + uint16_t y_start; + uint16_t x_end; + uint16_t y_end; +}; + void lcd_init(); +void draw_color_rectangle(struct LCD_rectangle r); +void send_command(uint16_t command); +void send_data(uint16_t data); +void set_drawing_area(struct LCD_rectangle r); +void start_DMA_upload(uint16_t * src, bool incrementSrc, uint16_t length); #endif \ No newline at end of file