aboutsummaryrefslogtreecommitdiff
path: root/lib/pbdrv/drv
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-06-26 15:44:26 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-06-26 15:44:26 +0200
commitee5d161f6153e1f9da73e477f63f38dcf52ca10c (patch)
tree926413950f64ed7b0f45f6b3551c16446ecd08d4 /lib/pbdrv/drv
parentc77d271d9cb86bf6893098ec6c431fc87945e6c9 (diff)
`make format`
Diffstat (limited to 'lib/pbdrv/drv')
-rw-r--r--lib/pbdrv/drv/arduino/mod.cpp17
-rw-r--r--lib/pbdrv/drv/rp2040/mod.c14
-rw-r--r--lib/pbdrv/drv/rp2040/pb-mod.h1
3 files changed, 15 insertions, 17 deletions
diff --git a/lib/pbdrv/drv/arduino/mod.cpp b/lib/pbdrv/drv/arduino/mod.cpp
index 27237d2..500edfa 100644
--- a/lib/pbdrv/drv/arduino/mod.cpp
+++ b/lib/pbdrv/drv/arduino/mod.cpp
@@ -3,14 +3,14 @@
#include <avr/delay.h>
#include <FreeRTOS.h>
-#include <timers.h>
#include <task.h>
+#include <timers.h>
-#include "../../pb.h"
-#include "../../pb-mod.h"
-#include "../../pb-types.h"
#include "../../pb-buf.h"
#include "../../pb-mem.h"
+#include "../../pb-mod.h"
+#include "../../pb-types.h"
+#include "../../pb.h"
static void async_pb_i2c_recv(void * _msg, uint32_t _) {
pb_buf_t * msg = (pb_buf_t *) _msg;
@@ -23,8 +23,7 @@ static void recv_event(int bytes) {
pb_buf_t * msg = (pb_buf_t *) pb_malloc(sizeof(pb_buf_t));
msg->data = (char *) pb_malloc(bytes);
msg->size = 0;
- while (Wire.available())
- msg->data[msg->size++] = Wire.read();
+ while (Wire.available()) msg->data[msg->size++] = Wire.read();
// defer pb_i2c_recv call
xTimerPendFunctionCallFromISR(async_pb_i2c_recv, msg, 0, NULL);
@@ -66,7 +65,7 @@ void init(void);
//! FreeRTOS loop task
void loop_task() {
- for(;;) {
+ for (;;) {
loop();
if (serialEventRun) serialEventRun();
}
@@ -90,8 +89,8 @@ int main(void) {
init(); // call arduino internal setup
setup(); // call regular arduino setup
pb_setup(); // call pbdrv-mod setup
- xTaskCreate((TaskFunction_t) loop_task, "loop", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL);
+ xTaskCreate((TaskFunction_t) loop_task, "loop", configMINIMAL_STACK_SIZE,
+ NULL, tskIDLE_PRIORITY + 1, NULL);
vTaskStartScheduler(); // start freertos scheduler
return 0;
}
-
diff --git a/lib/pbdrv/drv/rp2040/mod.c b/lib/pbdrv/drv/rp2040/mod.c
index bca38d0..b031af9 100644
--- a/lib/pbdrv/drv/rp2040/mod.c
+++ b/lib/pbdrv/drv/rp2040/mod.c
@@ -1,11 +1,11 @@
-#include "../../pb.h"
-#include "../../pb-types.h"
+#include "../../pb-buf.h"
#include "../../pb-mod.h"
#include "../../pb-send.h"
-#include "../../pb-buf.h"
+#include "../../pb-types.h"
+#include "../../pb.h"
-#include <hardware/i2c.h>
#include <hardware/gpio.h>
+#include <hardware/i2c.h>
#include <pico/i2c_slave.h>
#define PB_I2C_S i2c0
@@ -17,7 +17,7 @@ uint8_t i2c_msg_buf[BUF_SIZE];
size_t i2c_msg_buf_sz = 0;
// This function is called from the I2C ISR
-static void recv_event(i2c_inst_t *i2c, i2c_slave_event_t event) {
+static void recv_event(i2c_inst_t * i2c, i2c_slave_event_t event) {
switch (event) {
case I2C_SLAVE_RECEIVE: {
if (i2c_msg_buf_sz == BUF_SIZE) return;
@@ -29,7 +29,8 @@ static void recv_event(i2c_inst_t *i2c, i2c_slave_event_t event) {
i2c_msg_buf_sz = 0;
break;
}
- default: break;
+ default:
+ break;
}
}
@@ -46,4 +47,3 @@ __weak void pb_i2c_send(i2c_addr_t addr, const uint8_t * buf, size_t sz) {
// false to write stop condition to i2c bus
i2c_write_timeout_us(PB_I2C_M, addr, buf, sz, false, PB_TIMEOUT_US);
}
-
diff --git a/lib/pbdrv/drv/rp2040/pb-mod.h b/lib/pbdrv/drv/rp2040/pb-mod.h
index 96edc70..7a4399e 100644
--- a/lib/pbdrv/drv/rp2040/pb-mod.h
+++ b/lib/pbdrv/drv/rp2040/pb-mod.h
@@ -18,4 +18,3 @@ void pb_setup();
#endif
#include "../../pb-mod.h"
-