summaryrefslogtreecommitdiff
path: root/src/main.c
blob: 233757bb6b69d4069f2b746cc36fea463ab1f8a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#define STM32F1
#include <stdint.h>
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
#include <ili9341.h>

#define LED_PIN GPIO13

int main(void) {
    // Enabling peripheral clocks
    rcc_periph_clock_enable(RCC_GPIOA);
    rcc_periph_clock_enable(RCC_GPIOB);
    rcc_periph_clock_enable(RCC_GPIOC);
	rcc_periph_clock_enable(RCC_SPI1);

    gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, LED_PIN);
    gpio_set(GPIOC, GPIO13);

    ILI_SetupGPIO();
    ILI_Setup();
     
    delayCycles(1000000);

    uint16_t colour = 0x0000;
    ILI_setAddrWindow(0, 0, 9, 9);
    for (int i = 0; i < 100; i++) {
        ILI_sendData((colour >> 8) & 0xFF);
        ILI_sendData(colour & 0xFF);
    }
    while (1) {
    }
}