| b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | #include "hal.h" |
| 2 | #include "PlatformCommon.h" |
| 3 | |
| 4 | CS_REGISTER_PAIR_S lcd_key_pins[] = |
| 5 | { |
| 6 | (int *) (APPS_PAD_BASE | 0x00d8), 0xA001, 0x0, // GPIO126, LCD BL |
| 7 | #ifndef CONFIG_SPI_LCD_3WIRE |
| 8 | (int *) (APPS_PAD_BASE | 0x0134), 0x1000, 0x0, // GPIO22, LCD RS |
| 9 | #endif |
| 10 | (int *) (APPS_PAD_BASE | 0x013c), 0x1000, 0x0, // GPIO24, LCD RESET |
| 11 | /* spi */ |
| 12 | (int *) (APPS_PAD_BASE | 0x0160), 0x1001, 0x0, // GPIO33, SPI SCL |
| 13 | (int *) (APPS_PAD_BASE | 0x0164), 0x1001, 0x0, // GPIO34, SPI CS |
| 14 | (int *) (APPS_PAD_BASE | 0x016c), 0x1001, 0x0, // GPIO36, SPI TX |
| 15 | |
| 16 | 0x0,0x0,0x0 // termination |
| 17 | }; |
| 18 | |
| 19 | void gpio_direction_output(int gpio, int value) |
| 20 | { |
| 21 | |
| 22 | const unsigned int offset[] = {0, 4, 8, 0x100}; |
| 23 | unsigned int gpio_base; |
| 24 | int bank = GPIO_TO_REG(gpio); |
| 25 | |
| 26 | gpio_base = GPIO0_BASE + offset[bank]; |
| 27 | *(VUINT_T *)(gpio_base + GPIO_SDR) |= GPIO_TO_BIT(gpio); |
| 28 | if (value) |
| 29 | *(VUINT_T *)(gpio_base + GPIO_PSR) |= GPIO_TO_BIT(gpio); |
| 30 | else |
| 31 | *(VUINT_T *)(gpio_base + GPIO_PCR) |= GPIO_TO_BIT(gpio); |
| 32 | } |
| 33 | |
| 34 | void asr_lcd_init(void) |
| 35 | { |
| 36 | ConfigRegWrite(lcd_key_pins); |
| 37 | SPI_Clk_Init(); |
| 38 | spi_lcd_init(); |
| 39 | } |