diff --git a/.vscode/settings.json b/.vscode/settings.json index 90879a8..77d7cb8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -22,6 +22,7 @@ "stm32f730xx.h": "c", "keyboard.h": "c", "gpio_helper.h": "c", - "stdint.h": "c" + "stdint.h": "c", + "clock.h": "c" } } \ No newline at end of file diff --git a/Makefile b/Makefile index 455c30a..2854fea 100644 --- a/Makefile +++ b/Makefile @@ -47,6 +47,7 @@ CFLAGS += -g CFLAGS += -fmessage-length=0 # (Set system to ignore semihosted junk) CFLAGS += --specs=nosys.specs +CFLAGS += -O0 # Linker directives. LSCRIPT = $(LD_SCRIPT) diff --git a/build/Laplace/clock.o b/build/Laplace/clock.o index 182dca0..1118602 100644 Binary files a/build/Laplace/clock.o and b/build/Laplace/clock.o differ diff --git a/build/Laplace/gpio_helper.o b/build/Laplace/gpio_helper.o index 1b90e95..0216c79 100644 Binary files a/build/Laplace/gpio_helper.o and b/build/Laplace/gpio_helper.o differ diff --git a/build/Laplace/keyboard.o b/build/Laplace/keyboard.o index b517e59..d20518c 100644 Binary files a/build/Laplace/keyboard.o and b/build/Laplace/keyboard.o differ diff --git a/build/Laplace/laplace.o b/build/Laplace/laplace.o index b93b56a..a45af19 100644 Binary files a/build/Laplace/laplace.o and b/build/Laplace/laplace.o differ diff --git a/build/Laplace/lcd.o b/build/Laplace/lcd.o new file mode 100644 index 0000000..f583644 Binary files /dev/null and b/build/Laplace/lcd.o differ diff --git a/build/Laplace/led.o b/build/Laplace/led.o index fb9c2e2..345b97c 100644 Binary files a/build/Laplace/led.o and b/build/Laplace/led.o differ diff --git a/build/Laplace/time.o b/build/Laplace/time.o index 5d25b1e..ab9a9f4 100644 Binary files a/build/Laplace/time.o and b/build/Laplace/time.o differ diff --git a/build/info_headers.o b/build/info_headers.o index f52abfd..f29ae28 100644 Binary files a/build/info_headers.o and b/build/info_headers.o differ diff --git a/build/main.bin b/build/main.bin index e40322c..9fc84ee 100755 Binary files a/build/main.bin and b/build/main.bin differ diff --git a/build/main.elf b/build/main.elf index 444eedc..9187d1d 100755 Binary files a/build/main.elf and b/build/main.elf differ diff --git a/build/main.o b/build/main.o index b560166..b36488c 100644 Binary files a/build/main.o and b/build/main.o differ diff --git a/build/start_handler.o b/build/start_handler.o index 7dbb809..24f8e3d 100644 Binary files a/build/start_handler.o and b/build/start_handler.o differ diff --git a/build/vector_table.o b/build/vector_table.o index e543fb5..f996f5f 100644 Binary files a/build/vector_table.o and b/build/vector_table.o differ diff --git a/build/working_main.bin b/build/working_main.bin new file mode 100755 index 0000000..db52213 Binary files /dev/null and b/build/working_main.bin differ diff --git a/build/working_main.elf b/build/working_main.elf new file mode 100755 index 0000000..6d5e910 Binary files /dev/null and b/build/working_main.elf differ diff --git a/src/Laplace/clock.c b/src/Laplace/clock.c index 7803302..e292f4a 100644 --- a/src/Laplace/clock.c +++ b/src/Laplace/clock.c @@ -1,4 +1,5 @@ #include "clock.h" +#include "../device/stm32f730xx.h" /* This should set the speed to 216MHz intead of just 48MHz */ void init_clock(){ @@ -78,7 +79,7 @@ void init_clock(){ // Set normal speed RCC->CFGR &= ~(RCC_CFGR_HPRE_Msk); - + /* // UNSAFE CODE // 23999<=>0b0101 1101 1011 1111 SysTick->LOAD &= ~(0b00000000111111111111111111111111); @@ -87,7 +88,9 @@ void init_clock(){ SysTick->VAL &= ~(0b00000000111111111111111111111111); //set some things in CSR SysTick->CTRL &= ~(0b00000000000000000000000000000111); - SysTick->CTRL |= 0b00000000000000000000000000000011; + SysTick->CTRL |= 0b00000000000000000000000000000011;*/ + + set_led_green(true); } /* OLD diff --git a/src/Laplace/clock.h b/src/Laplace/clock.h index da7fd2f..f60c307 100644 --- a/src/Laplace/clock.h +++ b/src/Laplace/clock.h @@ -7,8 +7,8 @@ #ifndef CLOCK_H #define CLOCK_H -#include "stdint.h" #include "../device/stm32f730xx.h" +#include "stdint.h" #include "led.h" /* diff --git a/src/Laplace/keyboard.h b/src/Laplace/keyboard.h index 942c240..fd742fe 100644 --- a/src/Laplace/keyboard.h +++ b/src/Laplace/keyboard.h @@ -8,6 +8,7 @@ #define KEYBOARD_H #include "gpio_helper.h" +#include "time.h" struct button{ uint8_t column; // ie: 2 diff --git a/src/Laplace/laplace.c b/src/Laplace/laplace.c index abc4c1b..8133c56 100644 --- a/src/Laplace/laplace.c +++ b/src/Laplace/laplace.c @@ -2,6 +2,7 @@ /* Initialize all needed peripherals, should be called early in your program */ void laplace_init(){ + init_clock(); /* led init */ enable_gpio_x_rcc(GPIO_B); led_init(); @@ -10,5 +11,5 @@ void laplace_init(){ enable_gpio_x_rcc(GPIO_C); //column (in) enable_gpio_x_rcc(GPIO_A); //row (out) keyboard_init(); - init_clock(); + lcd_init(); } \ No newline at end of file diff --git a/src/Laplace/laplace.h b/src/Laplace/laplace.h index e66addd..fca4239 100644 --- a/src/Laplace/laplace.h +++ b/src/Laplace/laplace.h @@ -11,6 +11,7 @@ #include "led.h" #include "keyboard.h" #include "clock.h" +#include "lcd.h" /* Initialize all needed peripherals, should be called early in your program */ void laplace_init(); diff --git a/src/Laplace/lcd.c b/src/Laplace/lcd.c new file mode 100644 index 0000000..dfa300d --- /dev/null +++ b/src/Laplace/lcd.c @@ -0,0 +1,55 @@ +#include "lcd.h" + +/* 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; + //init_DMA(); + draw_screen(); +} + +void draw_screen(){ + +} + +// send command to the LCD +void send_command(uint16_t command){ + *COMMAND_ADDRESS = command; +} + +// send data to the LCD, should be called after sending the command +void send_data(uint16_t data){ + *DATA_ADDRESS = data; +} + +// we assume orientations is portrait +void set_drawing_area(r/*TODO*/){ + send_command(MEMORY_ACCESS_CONTROL); + send_data(0x00); + + send_command(COLUMN_ADDRESS_SET); + send_data(); + + send_command(PAGE_ADDRESS_SET); + send_data(); +} + +void start_DMA_upload(){ + +} + +/*void init_DMA(){ + // clear specified bits + DMA2_Stream0->CR &= ~(0b00000001111000000111110011000001); + // set them to the correct value*/ + /* DIR = 2 = 0b10 + * MSIZE = 1 = 0b1 + * PSIZE = 1 = 0b1 + * MBURST = 1 = 0b1 + * PBURST = 1 = 0b1 + * MINC = false = 0b0 */ + /*DMA2_Stream0->CR |= 0b00000000101000000010100010000000; + // DataAddress is 0x60020000 = 0b0110 0000 0000 0010 0000 0000 0000 0000 + DMA2_Stream0->M0AR &= ~(0b11111111111111111111111111111111); + DMA2_Stream0->M0AR |= 0b01100000000000100000000000000000; +}*/ \ No newline at end of file diff --git a/src/Laplace/lcd.h b/src/Laplace/lcd.h new file mode 100644 index 0000000..d148df7 --- /dev/null +++ b/src/Laplace/lcd.h @@ -0,0 +1,40 @@ +/** @file lcd.h + * + * @brief Control the lcd + * + */ + +#ifndef LCD_H +#define LCD_H + +#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 +#define NOP 0x00 +#define RESET 0x01 +#define READ_DISPLAY_ID 0x04 +#define SLEEP_IN 0x10 +#define SLEEP_OUT 0x11 +#define DISPLAY_INVERSION_OFF 0x20 +#define DISPLAY_INVERSION_ON 0x21 +#define DISPLAY_OFF 0x28 +#define DISPLAY_ON 0x29 +#define COLUMN_ADDRESS_SET 0x2A +#define PAGE_ADDRESS_SET 0x2B +#define MEMORY_WRITE 0x2C +#define MEMORY_READ 0x2E +#define TEARING_EFFECT_LINE_ON 0x35 +#define MEMORY_ACCESS_CONTROL 0x36 +#define PIXEL_FORMAT_SET 0x3A +#define FRAME_RATE_CONTROL 0xC6 +#define POSITIVE_VOLTAGE_GAMMA_CONTROL 0xE0 +#define NEGATIVE_VOLTAGE_GAMMA_CONTROL 0xE1 + +void lcd_init(); + +#endif \ No newline at end of file diff --git a/src/main.c b/src/main.c index 235f83e..b520001 100644 --- a/src/main.c +++ b/src/main.c @@ -34,9 +34,9 @@ void main_entry(){ }*/ set_led_blue(true); - ms_wait(5000); + ms_wait(500); set_led_blue(false); - ms_wait(5000); + ms_wait(500); } } \ No newline at end of file diff --git a/src/main.h b/src/main.h index 8626abb..a4991d3 100644 --- a/src/main.h +++ b/src/main.h @@ -11,6 +11,7 @@ #include "Laplace/led.h" #include "Laplace/keyboard.h" #include "Laplace/time.h" +#include "Laplace/clock.h" /* our main function */ void main_entry();