Added somethings

This commit is contained in:
2023-11-01 21:39:57 +00:00
parent 2b117b4b33
commit 776eb15c59
2 changed files with 21 additions and 11 deletions

View File

@@ -1,22 +1,27 @@
menu "PMS5003" menu "PMS5003"
config PMS5003_ENABLED config PMS5003_ENABLED
bool "PMS5003 Enabled" bool "PMS5003 Enabled"
default y default y
config PMS5003_UART_PORT config PMS5003_UART_PORT
int "PMS5003 UART PORT" int "PMS5003 UART PORT"
default 0 default 0
depends on PMS5003_ENABLED depends on PMS5003_ENABLED
config PMS5003_UART_TX config PMS5003_UART_TX
int "PMS5003 UART Tx GPIO Pin" int "PMS5003 UART Tx GPIO Pin"
default 4 default 4
depends on PMS5003_ENABLED depends on PMS5003_ENABLED
config PMS5003_UART_RX config PMS5003_UART_RX
int "PMS5003 UART Rx GPIO Pin" int "PMS5003 UART Rx GPIO Pin"
default 5 default 5
depends on PMS5003_ENABLED depends on PMS5003_ENABLED
config PMS5003_SET_GPIO
int "PMS5003 Set Pin - (should be connected to pin 3 of PMS5003)"
default 6
depends on PMS5003_ENABLED
config PMS5003_PERIOD_POLL config PMS5003_PERIOD_POLL
int "Period to poll the PMS5003 in seconds" int "Period to poll the PMS5003 in seconds"

View File

@@ -1,5 +1,7 @@
#include "pms5003.h" #include "pms5003.h"
#include "driver/gpio.h"
#include "driver/uart.h" #include "driver/uart.h"
#include "hal/gpio_types.h"
#include "hal/uart_types.h" #include "hal/uart_types.h"
#define START_CHAR_1 0x42 #define START_CHAR_1 0x42
@@ -13,17 +15,20 @@ pms5003_err pms5003_init() {
const uart_port_t uart_num = CONFIG_PMS5003_UART_PORT; const uart_port_t uart_num = CONFIG_PMS5003_UART_PORT;
uart_set_pin(uart_num, CONFIG_PMS5003_UART_TX, CONFIG_PMS5003_UART_RX, -1, -1); uart_set_pin(uart_num, CONFIG_PMS5003_UART_TX, CONFIG_PMS5003_UART_RX, -1, -1);
uart_config_t uart_config = { uart_config_t uart_config = {
.baud_rate = DEFAULT_BAUD, .baud_rate = DEFAULT_BAUD,
.data_bits = UART_DATA_8_BITS, .data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE, .parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1, .stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE, .flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.rx_flow_ctrl_thresh = 122, .rx_flow_ctrl_thresh = 122, // No idea what this does - it's a default I found somewhere
}; };
gpio_set_direction(CONFIG_PMS5003_SET_GPIO, GPIO_MODE_DEF_OUTPUT);
// Datasheet has 10k pull-up
gpio_set_pull_mode(CONFIG_PMS5003_SET_GPIO, GPIO_PULLUP_ONLY);
return PMS5003_OK; return PMS5003_OK;
} }
pms5003_err pms5003_read(void) { pms5003_err pms5003_read(void) {
// uart_read_bytes
return PMS5003_OK; return PMS5003_OK;
} }