diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-06-14 12:16:36 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-06-14 12:16:36 +0200 |
commit | ef162ca3445d9adb000d7dfd1b68b181ef958926 (patch) | |
tree | 25c62f409323c0fa6be7c9034bc04ee2bb18ef50 /main | |
parent | 2cf895332ffd54ea1a43b090859943665709e420 (diff) |
clean up pbdrv naming
Diffstat (limited to 'main')
-rw-r--r-- | main/i2c.c | 4 | ||||
-rw-r--r-- | main/init.c | 2 | ||||
-rw-r--r-- | main/mod.c | 4 | ||||
-rw-r--r-- | main/pbdrv.c | 28 | ||||
-rw-r--r-- | main/pbdrv.h | 6 |
5 files changed, 22 insertions, 22 deletions
@@ -30,7 +30,7 @@ // return array; // } -void pbdrv_i2c_recv(const uint8_t * a, size_t b) { +void pb_i2c_recv(const uint8_t * a, size_t b) { printf("%.*s", b, a); } @@ -45,7 +45,7 @@ void bus_task() { while (true) { vTaskDelay(10 / portTICK_PERIOD_MS); - pbdrv_i2c_send(0x69, (uint8_t *) "bbbbbbbb", 9); + pb_i2c_send(0x69, (uint8_t *) "bbbbbbbb", 9); } // while(1) { diff --git a/main/init.c b/main/init.c index c1b6e9b..2d6f33d 100644 --- a/main/init.c +++ b/main/init.c @@ -32,7 +32,7 @@ static void init_i2c() { gpio_set_function(CFG_SDA_PIN, GPIO_FUNC_I2C); gpio_set_function(CFG_SCL_PIN, GPIO_FUNC_I2C); - pbdrv_setup(); + pb_setup(); } static void async_init() { @@ -1,5 +1,5 @@ #include "pb-mod.h" -const char * PBDRV_MOD_NAME = "main controller"; -const i2c_addr_t PBDRV_MOD_ADDR = 0x20; +const char * PB_MOD_NAME = "main controller"; +const i2c_addr_t PB_MOD_ADDR = 0x20; diff --git a/main/pbdrv.c b/main/pbdrv.c index 9d9e499..323afbe 100644 --- a/main/pbdrv.c +++ b/main/pbdrv.c @@ -1,4 +1,4 @@ -#include "pbdrv.h" +#include "pb.h" #include "pb.h" #include "pb-types.h" @@ -11,7 +11,7 @@ #include <FreeRTOS.h> #include <timers.h> -#define PBDRV_I2C i2c0 +#define PB_I2C i2c0 #define BUF_SIZE 256 #define MSGS_MAX 4 @@ -23,15 +23,15 @@ typedef struct { static i2c_msg_buf_t msgs[MSGS_MAX]; static size_t msg_index = 0; -static void async_pbdrv_i2c_recv(void * _msg, uint32_t _) { +static void async_pb_i2c_recv(void * _msg, uint32_t _) { i2c_msg_buf_t * msg = _msg; - pbdrv_i2c_recv(msg->data, msg->size); + pb_i2c_recv(msg->data, msg->size); } static void msg_complete(i2c_msg_buf_t * msg) { - // defer pbdrv_i2c_recv call to FreeRTOS scheduler as pbdrv_i2c_recv takes + // defer pb_i2c_recv call to FreeRTOS scheduler as pb_i2c_recv takes // too long to return from an ISR - xTimerPendFunctionCallFromISR(async_pbdrv_i2c_recv, msg, 0, NULL); + xTimerPendFunctionCallFromISR(async_pb_i2c_recv, msg, 0, NULL); // prepare next message for use msg_index = (msg_index + 1) % MSGS_MAX; @@ -45,7 +45,7 @@ static void recv_event(i2c_inst_t *i2c, i2c_slave_event_t event) { switch (event) { case I2C_SLAVE_RECEIVE: { if (msg->size == BUF_SIZE) return; - msg->data[msg->size++] = i2c_read_byte_raw(PBDRV_I2C); + msg->data[msg->size++] = i2c_read_byte_raw(PB_I2C); break; } case I2C_SLAVE_FINISH: { @@ -56,17 +56,17 @@ static void recv_event(i2c_inst_t *i2c, i2c_slave_event_t event) { } } -void pbdrv_setup() { - i2c_init(PBDRV_I2C, PB_CLOCK_SPEED_HZ); - i2c_slave_init(PBDRV_I2C, PBDRV_MOD_ADDR, &recv_event); +void pb_setup() { + i2c_init(PB_I2C, PB_CLOCK_SPEED_HZ); + i2c_slave_init(PB_I2C, PB_MOD_ADDR, &recv_event); } -__weak void pbdrv_i2c_send(i2c_addr_t addr, const uint8_t * buf, size_t sz) { - i2c_set_slave_mode(PBDRV_I2C, false, PBDRV_MOD_ADDR); +__weak void pb_i2c_send(i2c_addr_t addr, const uint8_t * buf, size_t sz) { + i2c_set_slave_mode(PB_I2C, false, PB_MOD_ADDR); // false to write stop condition to i2c bus - i2c_write_timeout_us(PBDRV_I2C, addr, buf, sz, false, PB_TIMEOUT_US); + i2c_write_timeout_us(PB_I2C, addr, buf, sz, false, PB_TIMEOUT_US); - i2c_set_slave_mode(PBDRV_I2C, true, PBDRV_MOD_ADDR); + i2c_set_slave_mode(PB_I2C, true, PB_MOD_ADDR); } diff --git a/main/pbdrv.h b/main/pbdrv.h index d0d70c2..0b4ca21 100644 --- a/main/pbdrv.h +++ b/main/pbdrv.h @@ -4,7 +4,7 @@ /** * This is the RP2040 puzzle bus driver. This file is no longer inside - * lib/pbdrv/drv/rp2040 as it is tightly coupled to both the pico-sdk and + * lib/pb//rp2040 as it is tightly coupled to both the pico-sdk and * freertos functions. I have tried to get FreeRTOS to play nicely with the * CMake subproject layout, but the pico-sdk and the rp2040 port of freertos * both rely on CMake's import() functionality, which makes using FreeRTOS in a @@ -19,7 +19,7 @@ extern "C" { #endif //! puzzle bus driver setup -void pbdrv_setup(); +void pb_setup(); /** * While the RP2040's datasheet claims it supports multi-master configurations @@ -33,7 +33,7 @@ void pbdrv_setup(); * the time period between the invocation of this function and the bus becoming * idle (and the message is sent). */ -void pbdrv_i2c_send(i2c_addr_t addr, const uint8_t * buf, size_t sz); +void pb_i2c_send(i2c_addr_t addr, const uint8_t * buf, size_t sz); #ifdef __cplusplus } |