Skip to content

Commit 10d6871

Browse files
committed
board: update drivers
1 parent 0b4e069 commit 10d6871

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

main/src/board/pn532.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,24 @@
55
* Author: Jack Chen <redchenjs@live.com>
66
*/
77

8+
#include "esp_log.h"
9+
810
#include "driver/gpio.h"
911

12+
#define TAG "pn532"
13+
1014
void pn532_setpin_reset(uint8_t val)
1115
{
1216
gpio_set_level(CONFIG_PN532_RST_PIN, val);
1317
}
1418

1519
void pn532_init(void)
1620
{
17-
gpio_set_direction(CONFIG_PN532_RST_PIN, GPIO_MODE_OUTPUT);
21+
gpio_config_t io_conf = {
22+
.mode = GPIO_MODE_OUTPUT,
23+
.pin_bit_mask = BIT64(CONFIG_PN532_RST_PIN),
24+
};
25+
gpio_config(&io_conf);
1826

19-
pn532_setpin_reset(0);
27+
ESP_LOGI(TAG, "initialized, rst: %d", CONFIG_PN532_RST_PIN);
2028
}

main/src/board/st7735.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "driver/ledc.h"
1414
#include "driver/spi_master.h"
1515

16+
#include "drivers/gdisp/ST7735/ST7735.h"
17+
1618
#include "chip/spi.h"
1719
#include "board/st7735.h"
1820

@@ -26,10 +28,11 @@ void st7735_init_board(void)
2628
{
2729
memset(hspi_trans, 0x00, sizeof(hspi_trans));
2830

29-
gpio_set_direction(CONFIG_DEVICE_DC_PIN, GPIO_MODE_OUTPUT);
30-
gpio_set_direction(CONFIG_DEVICE_RST_PIN, GPIO_MODE_OUTPUT);
31-
gpio_set_level(CONFIG_DEVICE_DC_PIN, 0);
32-
gpio_set_level(CONFIG_DEVICE_RST_PIN, 0);
31+
gpio_config_t io_conf = {
32+
.mode = GPIO_MODE_OUTPUT,
33+
.pin_bit_mask = BIT64(CONFIG_DEVICE_DC_PIN) | BIT64(CONFIG_DEVICE_RST_PIN),
34+
};
35+
gpio_config(&io_conf);
3336

3437
ledc_timer_config_t ledc_timer = {
3538
.duty_resolution = LEDC_TIMER_8_BIT,
@@ -103,7 +106,7 @@ void st7735_write_buff(uint8_t *buff, uint32_t n)
103106
void st7735_refresh_gram(uint8_t *gram)
104107
{
105108
hspi_trans[0].length = 8,
106-
hspi_trans[0].tx_data[0] = 0x2C; // Set Write RAM
109+
hspi_trans[0].tx_data[0] = ST7735_RAMWR;
107110
hspi_trans[0].user = (void*)0;
108111
hspi_trans[0].flags = SPI_TRANS_USE_TXDATA;
109112

main/src/board/st7789.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "driver/ledc.h"
1414
#include "driver/spi_master.h"
1515

16+
#include "drivers/gdisp/ST7789/ST7789.h"
17+
1618
#include "chip/spi.h"
1719
#include "board/st7789.h"
1820

@@ -26,10 +28,11 @@ void st7789_init_board(void)
2628
{
2729
memset(hspi_trans, 0x00, sizeof(hspi_trans));
2830

29-
gpio_set_direction(CONFIG_DEVICE_DC_PIN, GPIO_MODE_OUTPUT);
30-
gpio_set_direction(CONFIG_DEVICE_RST_PIN, GPIO_MODE_OUTPUT);
31-
gpio_set_level(CONFIG_DEVICE_DC_PIN, 0);
32-
gpio_set_level(CONFIG_DEVICE_RST_PIN, 0);
31+
gpio_config_t io_conf = {
32+
.mode = GPIO_MODE_OUTPUT,
33+
.pin_bit_mask = BIT64(CONFIG_DEVICE_DC_PIN) | BIT64(CONFIG_DEVICE_RST_PIN),
34+
};
35+
gpio_config(&io_conf);
3336

3437
ledc_timer_config_t ledc_timer = {
3538
.duty_resolution = LEDC_TIMER_8_BIT,
@@ -103,7 +106,7 @@ void st7789_write_buff(uint8_t *buff, uint32_t n)
103106
void st7789_refresh_gram(uint8_t *gram)
104107
{
105108
hspi_trans[0].length = 8,
106-
hspi_trans[0].tx_data[0] = 0x2C; // Set Write RAM
109+
hspi_trans[0].tx_data[0] = ST7789_RAMWR;
107110
hspi_trans[0].user = (void*)0;
108111
hspi_trans[0].flags = SPI_TRANS_USE_TXDATA;
109112

0 commit comments

Comments
 (0)