From 519ffcefbe607dcb89dd9da654628dd3b0c588eb Mon Sep 17 00:00:00 2001 From: ThomasintAnker Date: Fri, 31 May 2024 00:00:19 +0200 Subject: Working i2c+utp wo extra functionality --- main/i2c.c | 1 + main/i2c.h | 1 + main/init.c | 2 ++ main/main.c | 2 +- 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/main/i2c.c b/main/i2c.c index b324124..2615d0a 100644 --- a/main/i2c.c +++ b/main/i2c.c @@ -38,6 +38,7 @@ void init_addr_array(uint8_t array[], int size) { } } +// Make sure that current addresses are checked (modules), and invalid addresses are ignore (neotrellis slave) uint8_t* scan_bus(uint8_t *array) { int ret; int i = 0; diff --git a/main/i2c.h b/main/i2c.h index 5ad5cfb..05acb1c 100644 --- a/main/i2c.h +++ b/main/i2c.h @@ -1,5 +1,6 @@ #pragma once // https://github.com/raspberrypi/pico-examples/tree/master/i2c +// https://www.raspberrypi.com/documentation/microcontrollers/raspberry-pi-pico.html #include #include diff --git a/main/init.c b/main/init.c index 08177c7..fee3a6a 100644 --- a/main/init.c +++ b/main/init.c @@ -24,8 +24,10 @@ static void init_wifi() { // enable 'station' mode (connect to an access point instead of acting like one) cyw43_arch_enable_sta_mode(); + /* WERKT GEWOON NIET MET DEZE LIJNEN CODE */ // if (cyw43_arch_wifi_connect_timeout_ms(CONF_NET_SSID, CONF_NET_PASS, CONF_NET_AUTH, CONF_NET_CONN_TIMEOUT)) // panic("cyw43_arch_wifi_connect failed\n"); + /* WERKT GEWOON NIET MET DEZE LIJNEN CODE */ printf("connected to Wi-Fi\n"); diff --git a/main/main.c b/main/main.c index 19dd3cd..b38030f 100644 --- a/main/main.c +++ b/main/main.c @@ -24,7 +24,7 @@ int main() { init(); xTaskCreate((TaskFunction_t) blink_task, "blink", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, NULL); - //xTaskCreate((TaskFunction_t) serve_task, "serve", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, NULL); + xTaskCreate((TaskFunction_t) serve_task, "serve", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, NULL); xTaskCreate((TaskFunction_t) bus_task, "bus", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, NULL); vTaskStartScheduler(); -- cgit v1.2.3 From 377644354f15d283f37450bd7a473153d681316d Mon Sep 17 00:00:00 2001 From: ThomasintAnker Date: Fri, 31 May 2024 02:19:28 +0200 Subject: added queue for bbetween thread-communication --- main/i2c.c | 15 ++++++++++++++- main/main.c | 14 ++++++++++++++ main/sock.c | 15 +++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/main/i2c.c b/main/i2c.c index 2615d0a..e42e0b1 100644 --- a/main/i2c.c +++ b/main/i2c.c @@ -7,6 +7,11 @@ #include #include +#include +#include + +extern QueueHandle_t queue; + void init_i2c() { i2c_init(I2C_PORT, 100 * 1000); // currently at 100kHz @@ -77,11 +82,12 @@ void bus_task() { // printf("Bus scan!"); scan_bus(found); + uint8_t data; for(int i = 0; i < MAX_SLAVES; i++){ if( found[i] == 0x00 ) break; - uint8_t data = 0x01; + data = 0x01; // send data to found slave address write_i2c(found[i], &data, 1); @@ -90,5 +96,12 @@ void bus_task() { // request update from slave addr at found[i] //write_i2c(); } + + uint8_t rcvData[2]; + if(xQueueReceive(queue, &rcvData, portMAX_DELAY) == pdPASS){ + write_i2c(rcvData[0], &rcvData[1], sizeof(rcvData[1])); + } else { + printf("Something went wrong at queue receive!\n"); + } } } diff --git a/main/main.c b/main/main.c index b38030f..33912ec 100644 --- a/main/main.c +++ b/main/main.c @@ -1,4 +1,5 @@ #include +#include #include #include @@ -9,6 +10,8 @@ #include "sock.h" #include "i2c.h" +QueueHandle_t queue; + void blink_task() { await_init(); // `blink_task` uses GPIO @@ -23,10 +26,21 @@ void blink_task() { int main() { init(); + // change queue size(?) + queue + uint8_t i2cData[2]; + queue = xQueueCreate(10, sizeof(i2cData)); + xTaskCreate((TaskFunction_t) blink_task, "blink", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, NULL); xTaskCreate((TaskFunction_t) serve_task, "serve", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, NULL); xTaskCreate((TaskFunction_t) bus_task, "bus", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, NULL); vTaskStartScheduler(); + + while(1) { + // we should have never gotten here + printf("Why are we here?!\n"); + } + + return 0; } diff --git a/main/sock.c b/main/sock.c index 4f50981..5c8644b 100644 --- a/main/sock.c +++ b/main/sock.c @@ -5,11 +5,16 @@ #include #include +#include +#include + #include "init.h" #include "config.h" #include "puzbusv1.h" #include "sock.h" +extern QueueHandle_t queue; + struct netconn* current_connection = NULL; struct pb_msg recv_msg; @@ -35,15 +40,25 @@ void i2c_send(uint16_t addr, const char * data, size_t data_size) { } void i2c_recv(uint16_t addr, const char * data, size_t data_size) { + /* printf("address: 0x%02x\n", addr); printf("data: \"%.*s\"\n", data_size, data); // send message back char reply[] = "Test message back!"; i2c_send(0x69, reply, strlen(reply)); + */ // TODO: this function should forward the recieved message onto the puzzle // bus instead of printing/replying + // using queueu -> i2c_write only accepts uint8_t addr, and uint8_t data ._. + + printf("Sending data over i2c"); + uint8_t i2cData[2] = {addr, 0x00}; + if(xQueueSend(queue, &i2cData, portMAX_DELAY) != pdPASS) { + printf("Something went wrong!"); + } + } void recv_handler(struct netconn* conn, struct netbuf* buf) { -- cgit v1.2.3 From b865921e5dcf2ae2d6532b88eba1a0a49998eb27 Mon Sep 17 00:00:00 2001 From: ThomasintAnker Date: Fri, 31 May 2024 15:01:11 +0200 Subject: shenanigans --- main/i2c.c | 39 +++++++++++++++++++++++---------------- main/init.c | 4 ++-- main/sock.c | 6 ++++-- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/main/i2c.c b/main/i2c.c index e42e0b1..5cad081 100644 --- a/main/i2c.c +++ b/main/i2c.c @@ -49,14 +49,16 @@ uint8_t* scan_bus(uint8_t *array) { int i = 0; uint8_t rxdata; - for(int addr = 0; addr < (1<<7); addr++) { + for(int addr = 1; addr < (1<<7); addr++) { // ignore reserved addresses // These are any addresses of the form 000 0xxx or 111 1xxx - if( reserved_addr(addr) ){ - ret = PICO_ERROR_GENERIC; - }else{ - ret = i2c_read_blocking(I2C_PORT, addr, &rxdata, 1, false); - } + + // if( reserved_addr(addr) ){ + // ret = PICO_ERROR_GENERIC; + // }else{ + // + ret = i2c_read_blocking(I2C_PORT, addr, &rxdata, 1, false); + //} // if acknowledged -> ret == number of bytes sent if(ret > 0){ @@ -77,31 +79,36 @@ void bus_task() { int i = 0; uint8_t found[MAX_SLAVES]; init_addr_array(found, MAX_SLAVES); + scan_bus(found); while(1) { // printf("Bus scan!"); - scan_bus(found); uint8_t data; for(int i = 0; i < MAX_SLAVES; i++){ if( found[i] == 0x00 ) - break; + continue; - data = 0x01; - // send data to found slave address - write_i2c(found[i], &data, 1); + read_i2c(found[i], &data, 2); + if(data > 0) { + printf("Data: %d", data); + } + + // data = 0x01; + // // send data to found slave address + // write_i2c(found[i], &data, 1); + + // data = 0x02; + // write_i2c(found[i], &data, 1); - data = 0x02; - write_i2c(found[i], &data, 1); // request update from slave addr at found[i] //write_i2c(); } uint8_t rcvData[2]; - if(xQueueReceive(queue, &rcvData, portMAX_DELAY) == pdPASS){ + if(xQueueReceive(queue, &rcvData, 5) == pdPASS){ + printf("Send to address: %d, datat: %d\n", rcvData[0], rcvData[1]); write_i2c(rcvData[0], &rcvData[1], sizeof(rcvData[1])); - } else { - printf("Something went wrong at queue receive!\n"); } } } diff --git a/main/init.c b/main/init.c index fee3a6a..4ab373e 100644 --- a/main/init.c +++ b/main/init.c @@ -25,8 +25,8 @@ static void init_wifi() { cyw43_arch_enable_sta_mode(); /* WERKT GEWOON NIET MET DEZE LIJNEN CODE */ - // if (cyw43_arch_wifi_connect_timeout_ms(CONF_NET_SSID, CONF_NET_PASS, CONF_NET_AUTH, CONF_NET_CONN_TIMEOUT)) - // panic("cyw43_arch_wifi_connect failed\n"); + if (cyw43_arch_wifi_connect_timeout_ms(CONF_NET_SSID, CONF_NET_PASS, CONF_NET_AUTH, CONF_NET_CONN_TIMEOUT)) + panic("cyw43_arch_wifi_connect failed\n"); /* WERKT GEWOON NIET MET DEZE LIJNEN CODE */ printf("connected to Wi-Fi\n"); diff --git a/main/sock.c b/main/sock.c index 5c8644b..434694f 100644 --- a/main/sock.c +++ b/main/sock.c @@ -55,8 +55,8 @@ void i2c_recv(uint16_t addr, const char * data, size_t data_size) { printf("Sending data over i2c"); uint8_t i2cData[2] = {addr, 0x00}; - if(xQueueSend(queue, &i2cData, portMAX_DELAY) != pdPASS) { - printf("Something went wrong!"); + if(xQueueSend(queue, &i2cData, portMAX_DELAY) == pdPASS) { + printf("Socket send data to address: %d, data: %d", i2cData[0], i2cData[1]); } } @@ -70,8 +70,10 @@ void recv_handler(struct netconn* conn, struct netbuf* buf) { netbuf_data(buf, (void**)&data, &len); // continue early if more data is needed to complete message + printf("yeetus deletus defeatus"); if (!pb_read(&recv_msg, data, len)) continue; + printf("yeetus deletus defeatus v2!"); // forward received message to puzzle bus i2c_recv(recv_msg.addr, recv_msg.data, recv_msg.length); free(recv_msg.data); -- cgit v1.2.3 From 2107d89060c345906534f9b0a9eb37e679cdbce8 Mon Sep 17 00:00:00 2001 From: ThomasintAnker Date: Fri, 31 May 2024 15:39:27 +0200 Subject: working coms between i2c and utp --- main/i2c.c | 20 -------------------- main/main.c | 3 --- main/sock.c | 25 ++++--------------------- 3 files changed, 4 insertions(+), 44 deletions(-) diff --git a/main/i2c.c b/main/i2c.c index 5cad081..c5547e0 100644 --- a/main/i2c.c +++ b/main/i2c.c @@ -7,11 +7,6 @@ #include #include -#include -#include - -extern QueueHandle_t queue; - void init_i2c() { i2c_init(I2C_PORT, 100 * 1000); // currently at 100kHz @@ -94,21 +89,6 @@ void bus_task() { printf("Data: %d", data); } - // data = 0x01; - // // send data to found slave address - // write_i2c(found[i], &data, 1); - - // data = 0x02; - // write_i2c(found[i], &data, 1); - - // request update from slave addr at found[i] - //write_i2c(); - } - - uint8_t rcvData[2]; - if(xQueueReceive(queue, &rcvData, 5) == pdPASS){ - printf("Send to address: %d, datat: %d\n", rcvData[0], rcvData[1]); - write_i2c(rcvData[0], &rcvData[1], sizeof(rcvData[1])); } } } diff --git a/main/main.c b/main/main.c index 33912ec..051f500 100644 --- a/main/main.c +++ b/main/main.c @@ -1,5 +1,4 @@ #include -#include #include #include @@ -10,8 +9,6 @@ #include "sock.h" #include "i2c.h" -QueueHandle_t queue; - void blink_task() { await_init(); // `blink_task` uses GPIO diff --git a/main/sock.c b/main/sock.c index 33da03c..0755a5d 100644 --- a/main/sock.c +++ b/main/sock.c @@ -5,13 +5,11 @@ #include #include -#include -#include - #include "init.h" #include "config.h" #include "i2ctcpv1.h" #include "sock.h" +#include extern QueueHandle_t queue; @@ -40,25 +38,12 @@ void i2c_send(uint16_t addr, const char * data, size_t data_size) { } void i2c_recv(uint16_t addr, const char * data, size_t data_size) { - /* - printf("address: 0x%02x\n", addr); - printf("data: \"%.*s\"\n", data_size, data); - - // send message back - char reply[] = "Test message back!"; - i2c_send(0x69, reply, strlen(reply)); - */ - // TODO: this function should forward the recieved message onto the puzzle // bus instead of printing/replying // using queueu -> i2c_write only accepts uint8_t addr, and uint8_t data ._. - printf("Sending data over i2c"); - uint8_t i2cData[2] = {addr, 0x00}; - if(xQueueSend(queue, &i2cData, portMAX_DELAY) == pdPASS) { - printf("Socket send data to address: %d, data: %d", i2cData[0], i2cData[1]); - } - + printf("Addr: %lu, Data: %c, Data_size: %lu\n", addr, data[0], data_size); + i2c_write_blocking(i2c0, addr, data, data_size, false); } void recv_handler(struct netconn* conn, struct netbuf* buf) { @@ -70,10 +55,8 @@ void recv_handler(struct netconn* conn, struct netbuf* buf) { netbuf_data(buf, (void**)&data, &len); // continue early if more data is needed to complete message - printf("yeetus deletus defeatus"); - if (!i2ctcp_read(&recv_msg, data, len)) continue; + if (i2ctcp_read(&recv_msg, data, len) > 0) continue; - printf("yeetus deletus defeatus v2!"); // forward received message to puzzle bus i2c_recv(recv_msg.addr, recv_msg.data, recv_msg.length); free(recv_msg.data); -- cgit v1.2.3 From aca4c7549b2dc8d69931dca7c679c267b146ec48 Mon Sep 17 00:00:00 2001 From: ThomasintAnker Date: Mon, 3 Jun 2024 10:49:21 +0200 Subject: chaos --- main/CMakeLists.txt | 1 + main/i2c.c | 75 ++++++++++++++++++++++++++++++++++++++++------------- main/i2c.h | 6 +++++ main/main.c | 4 --- main/sock.c | 14 +++++----- 5 files changed, 71 insertions(+), 29 deletions(-) diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 6390d7c..cf23839 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -8,6 +8,7 @@ set(PICO_BOARD pico_w) include(lib/pico-sdk/pico_sdk_init.cmake) include(lib/FreeRTOS-Kernel/portable/ThirdParty/GCC/RP2040/FreeRTOS_Kernel_import.cmake) include(../i2ctcp/include.cmake) +include(../shared/include.cmake) project(puzzlebox_main C CXX ASM) diff --git a/main/i2c.c b/main/i2c.c index c5547e0..3347ecc 100644 --- a/main/i2c.c +++ b/main/i2c.c @@ -1,12 +1,23 @@ #include "i2c.h" #include "init.h" +#include "sock.h" +#include "pb/types.h" #include #include #include +#include #include #include +#include +#include +#include +#include + +uint8_t found[MAX_SLAVES]; +extern struct netconn* current_connection; + void init_i2c() { i2c_init(I2C_PORT, 100 * 1000); // currently at 100kHz @@ -38,26 +49,55 @@ void init_addr_array(uint8_t array[], int size) { } } +int write_read_i2c(uint8_t addr, uint8_t *input, size_t input_len, uint8_t *output, size_t output_len){ + // herhaalde start conditie voor direct lezen na i2c write (?) + int ret = write_i2c(addr, input, input_len); + if (ret < 0) { + printf("Write failure while writing data to bus.\n"); + return ret; + } + + // wait for response + absolute_time_t start_time = get_absolute_time(); + while ( absolute_time_diff_us(start_time, get_absolute_time()) / 1000 < MAX_TIMEOUT_TIME ){ + ret = read_i2c(addr, output, output_len); + if( ret > 0 ) { + return ret; + } + sleep_ms(1); + } + + printf("Timeout occurred while waiting for slave response.\n"); + return -1; +} + // Make sure that current addresses are checked (modules), and invalid addresses are ignore (neotrellis slave) uint8_t* scan_bus(uint8_t *array) { int ret; int i = 0; - uint8_t rxdata; + uint8_t rxdata, handshake_data; + init_addr_array(array, MAX_SLAVES); + + for(int addr = 1; addr < (1<<7); addr++) { + // fix handshake + ret = read_i2c(addr, &rxdata, 1); - for(int addr = 1; addr < (1<<7); addr++) { - // ignore reserved addresses - // These are any addresses of the form 000 0xxx or 111 1xxx + if ( ret <= 0 ) + continue; + + printf("found possible i2c slave on addr: %d\n", addr); + + // do handshake + ret = write_read_i2c(addr, (uint8_t*)pb_magic_msg, sizeof(pb_magic_msg), (uint8_t*)handshake_data, sizeof(pb_magic_res)); // fix data + length + everything - // if( reserved_addr(addr) ){ - // ret = PICO_ERROR_GENERIC; - // }else{ - // - ret = i2c_read_blocking(I2C_PORT, addr, &rxdata, 1, false); - //} - - // if acknowledged -> ret == number of bytes sent - if(ret > 0){ - printf("found i2c slave on addr: %d\n", addr); + if ( ret != sizeof(pb_magic_res)) + continue; + + if ( ret > 0 && (memcmp(handshake_data, pb_magic_res, sizeof(pb_magic_res)) == 0)) { + char buf[80]; + size_t s = snprintf(buf, "found i2c puzzle module at address: 0x%02x\n"); + netconn_write(current_connection, buf, s, NETCONN_COPY); + array[i] = addr; i++; } @@ -71,13 +111,10 @@ void bus_task() { // send updates at regular intervals await_init(); - int i = 0; - uint8_t found[MAX_SLAVES]; - init_addr_array(found, MAX_SLAVES); scan_bus(found); while(1) { - // printf("Bus scan!"); + // add check if bus is in use uint8_t data; for(int i = 0; i < MAX_SLAVES; i++){ @@ -90,5 +127,7 @@ void bus_task() { } } + + sleep_ms(1000); // wait for one second before next loop } } diff --git a/main/i2c.h b/main/i2c.h index 05acb1c..42cf34a 100644 --- a/main/i2c.h +++ b/main/i2c.h @@ -10,6 +10,7 @@ #define SCL_PIN 17 #define I2C_PORT i2c0 #define MAX_SLAVES 10 +#define MAX_TIMEOUT_TIME 50 //ms /** * \brief initialize all required gpio for i2c usage on the pico @@ -41,5 +42,10 @@ int read_i2c(uint8_t addr, uint8_t *output, size_t len); */ int write_i2c(uint8_t addr, uint8_t *input, size_t len); +/** + * \brief +*/ +int write_read_i2c(uint8_t addr, uint8_t *input, size_t input_len, uint8_t *output, size_t output_len); + /** \brief looking for slave addresses and requesting updates */ void bus_task(); diff --git a/main/main.c b/main/main.c index 051f500..7558a0b 100644 --- a/main/main.c +++ b/main/main.c @@ -23,10 +23,6 @@ void blink_task() { int main() { init(); - // change queue size(?) + queue - uint8_t i2cData[2]; - queue = xQueueCreate(10, sizeof(i2cData)); - xTaskCreate((TaskFunction_t) blink_task, "blink", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, NULL); xTaskCreate((TaskFunction_t) serve_task, "serve", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, NULL); xTaskCreate((TaskFunction_t) bus_task, "bus", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, NULL); diff --git a/main/sock.c b/main/sock.c index 0755a5d..08bec6b 100644 --- a/main/sock.c +++ b/main/sock.c @@ -11,8 +11,7 @@ #include "sock.h" #include -extern QueueHandle_t queue; - +extern uint8_t found[MAX_SLAVES]; struct netconn* current_connection = NULL; i2ctcp_msg_t recv_msg; @@ -40,26 +39,27 @@ void i2c_send(uint16_t addr, const char * data, size_t data_size) { void i2c_recv(uint16_t addr, const char * data, size_t data_size) { // TODO: this function should forward the recieved message onto the puzzle // bus instead of printing/replying - // using queueu -> i2c_write only accepts uint8_t addr, and uint8_t data ._. printf("Addr: %lu, Data: %c, Data_size: %lu\n", addr, data[0], data_size); i2c_write_blocking(i2c0, addr, data, data_size, false); } void recv_handler(struct netconn* conn, struct netbuf* buf) { - i2ctcp_read_reset(&recv_msg); + // i2ctcp_read_reset(&recv_msg); do { char* data; uint16_t len; netbuf_data(buf, (void**)&data, &len); + + scan_bus(found); // continue early if more data is needed to complete message - if (i2ctcp_read(&recv_msg, data, len) > 0) continue; + // if (i2ctcp_read(&recv_msg, data, len) > 0) continue; // forward received message to puzzle bus - i2c_recv(recv_msg.addr, recv_msg.data, recv_msg.length); - free(recv_msg.data); + // i2c_recv(recv_msg.addr, recv_msg.data, recv_msg.length); + // free(recv_msg.data); } while (netbuf_next(buf) >= 0); netbuf_delete(buf); -- cgit v1.2.3 From a98a2606c50023090d233fc16f3bb9516bfff0a8 Mon Sep 17 00:00:00 2001 From: ThomasintAnker Date: Mon, 3 Jun 2024 11:02:59 +0200 Subject: fix 1 --- main/i2c.c | 8 ++++---- main/i2c.h | 2 ++ main/sock.c | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/main/i2c.c b/main/i2c.c index 3347ecc..26723aa 100644 --- a/main/i2c.c +++ b/main/i2c.c @@ -75,12 +75,12 @@ int write_read_i2c(uint8_t addr, uint8_t *input, size_t input_len, uint8_t *outp uint8_t* scan_bus(uint8_t *array) { int ret; int i = 0; - uint8_t rxdata, handshake_data; + uint8_t* rxdata, handshake_data; init_addr_array(array, MAX_SLAVES); for(int addr = 1; addr < (1<<7); addr++) { // fix handshake - ret = read_i2c(addr, &rxdata, 1); + ret = read_i2c(addr, rxdata, 1); if ( ret <= 0 ) continue; @@ -88,14 +88,14 @@ uint8_t* scan_bus(uint8_t *array) { printf("found possible i2c slave on addr: %d\n", addr); // do handshake - ret = write_read_i2c(addr, (uint8_t*)pb_magic_msg, sizeof(pb_magic_msg), (uint8_t*)handshake_data, sizeof(pb_magic_res)); // fix data + length + everything + ret = write_read_i2c(addr, (uint8_t*)pb_magic_msg, sizeof(pb_magic_msg), &handshake_data, sizeof(pb_magic_res)); // fix data + length + everything if ( ret != sizeof(pb_magic_res)) continue; if ( ret > 0 && (memcmp(handshake_data, pb_magic_res, sizeof(pb_magic_res)) == 0)) { char buf[80]; - size_t s = snprintf(buf, "found i2c puzzle module at address: 0x%02x\n"); + size_t s = snprintf(buf, 80,"found i2c puzzle module at address: 0x%02x\n"); netconn_write(current_connection, buf, s, NETCONN_COPY); array[i] = addr; diff --git a/main/i2c.h b/main/i2c.h index 42cf34a..fcfa23b 100644 --- a/main/i2c.h +++ b/main/i2c.h @@ -47,5 +47,7 @@ int write_i2c(uint8_t addr, uint8_t *input, size_t len); */ int write_read_i2c(uint8_t addr, uint8_t *input, size_t input_len, uint8_t *output, size_t output_len); +uint8_t* scan_bus(uint8_t *array); + /** \brief looking for slave addresses and requesting updates */ void bus_task(); diff --git a/main/sock.c b/main/sock.c index 08bec6b..1913698 100644 --- a/main/sock.c +++ b/main/sock.c @@ -9,6 +9,7 @@ #include "config.h" #include "i2ctcpv1.h" #include "sock.h" +#include "i2c.h" #include extern uint8_t found[MAX_SLAVES]; -- cgit v1.2.3 From 5ebe68d8f1b6c290083dab6feff6f2fded5ac790 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Mon, 3 Jun 2024 11:04:48 +0200 Subject: AAAAAAAAAAAAAAA --- client/sock.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/sock.cpp b/client/sock.cpp index 95a3685..3490586 100644 --- a/client/sock.cpp +++ b/client/sock.cpp @@ -79,6 +79,8 @@ void PBSocket::sock_task() { char buf[80]; ssize_t bytes = read(_fd, buf, sizeof(buf)); + rl_printf("%.*s", bytes, buf); + continue; if (bytes == -1) { rl_printf("error: %s (%d)\n", strerror(errno), errno); break; -- cgit v1.2.3 From 3a8fcd3a27cc39a360e367a0492878e2e9aa8f28 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Mon, 3 Jun 2024 11:25:23 +0200 Subject: demo working kinda --- main/i2c.c | 11 ++++++++--- main/sock.c | 1 + shared/pb/types.h | 4 ++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/main/i2c.c b/main/i2c.c index 26723aa..5ce0507 100644 --- a/main/i2c.c +++ b/main/i2c.c @@ -75,7 +75,8 @@ int write_read_i2c(uint8_t addr, uint8_t *input, size_t input_len, uint8_t *outp uint8_t* scan_bus(uint8_t *array) { int ret; int i = 0; - uint8_t* rxdata, handshake_data; + uint8_t * rxdata; + uint8_t * handshake_data; init_addr_array(array, MAX_SLAVES); for(int addr = 1; addr < (1<<7); addr++) { @@ -85,15 +86,19 @@ uint8_t* scan_bus(uint8_t *array) { if ( ret <= 0 ) continue; - printf("found possible i2c slave on addr: %d\n", addr); + char buf[80]; + size_t s = snprintf(buf, 80,"found i2c puzzle module at address: 0x%02x\n", addr); + netconn_write(current_connection, buf, s, NETCONN_COPY); + printf("%.*s", s, buf); // do handshake - ret = write_read_i2c(addr, (uint8_t*)pb_magic_msg, sizeof(pb_magic_msg), &handshake_data, sizeof(pb_magic_res)); // fix data + length + everything + ret = write_read_i2c(addr, (uint8_t*)pb_magic_msg, sizeof(pb_magic_msg), handshake_data, sizeof(pb_magic_res)); // fix data + length + everything if ( ret != sizeof(pb_magic_res)) continue; if ( ret > 0 && (memcmp(handshake_data, pb_magic_res, sizeof(pb_magic_res)) == 0)) { + printf("this was an actual device!!!1111!\n"); char buf[80]; size_t s = snprintf(buf, 80,"found i2c puzzle module at address: 0x%02x\n"); netconn_write(current_connection, buf, s, NETCONN_COPY); diff --git a/main/sock.c b/main/sock.c index 1913698..af25d97 100644 --- a/main/sock.c +++ b/main/sock.c @@ -53,6 +53,7 @@ void recv_handler(struct netconn* conn, struct netbuf* buf) { uint16_t len; netbuf_data(buf, (void**)&data, &len); + printf("now scanning the bus!!!!\n"); scan_bus(found); // continue early if more data is needed to complete message diff --git a/shared/pb/types.h b/shared/pb/types.h index f2e2078..d4a65ed 100644 --- a/shared/pb/types.h +++ b/shared/pb/types.h @@ -6,9 +6,13 @@ extern "C" { #endif #ifdef __GNUC__ +#ifndef __packed #define __packed __attribute__((packed)) +#endif +#ifndef __weak #define __weak __attribute__((weak)) #endif +#endif #ifndef __packed #error Could not determine packed attribute for current compiler #define __packed -- cgit v1.2.3 From 50d5c4efb082a1ca5fc41f8aff493d5387fa796b Mon Sep 17 00:00:00 2001 From: ThomasintAnker Date: Sat, 15 Jun 2024 12:27:13 +0200 Subject: Handover doc --- docs/handover.adoc | 35 +++++++++++++++++++++++++++++++++++ docs/makefile | 1 + docs/share/glossary.adoc | 4 ++-- 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 docs/handover.adoc diff --git a/docs/handover.adoc b/docs/handover.adoc new file mode 100644 index 0000000..94896e3 --- /dev/null +++ b/docs/handover.adoc @@ -0,0 +1,35 @@ +:document: Handover +include::share/meta.adoc[] + +=== A Note Before Reading +The team of year 2023-2024 consisted of only software students, meaning no +hardware was developed in this year. We were tasked with simplifying the +software to the point where it would only have to be ported into the new hardware, +which was designed in the year 2022-2023. The goal of this year would be to create +a software framework which can be used to implement new puzzles and to make the +development process of these puzzles easier. + +== Project State +The current project state is as follows: No new hardware has been designed +or developed this year. The software was completely revised, now consisting of a +main controller, and multiple puzzle modules. The main controller (a RPI Pico W) +can interact with the different puzzle modules using an I^2^C bus. + +== What Went Wrong + +== Recommendations +kijk naar de documentatie maar verifieer alles op het laagste niveau + +Voor de volgende jaren: maak zo snel mogelijk prototypes, laat zien dat *iets* werkt + +ER MOET ONDERZOCHT WORDEN NAAR MULTIMASTER CONTROLLERS DIE OOK ALS SLAVE KUNNEN WORDEN GEADDRESSEERD (INTENS MOEILIJK TE VINDEN) + +i2c MOET, arbitration moet, Atmega328p zou geschikt zijn voor losse puzzelmodules + +-- +Maak een duidelijke waarschuwing" +- ga er niet van uit dat je het al weet, doe ff wat low level research over de onderwerpen + +rpi heeft programmable io modules, mogelijk via deze omweg rp2040 wel als MULTIMASTER met slave adresseerbaar +- rp2040 kan alleen 7-bit adressen hebben +include::share/footer.adoc[] diff --git a/docs/makefile b/docs/makefile index f175830..eb54a80 100644 --- a/docs/makefile +++ b/docs/makefile @@ -2,6 +2,7 @@ all: plan.pdf all: reqs.pdf all: research.pdf all: design.pdf +all: handover.pdf # include font.mk diff --git a/docs/share/glossary.adoc b/docs/share/glossary.adoc index 871a8e9..14c0374 100644 --- a/docs/share/glossary.adoc +++ b/docs/share/glossary.adoc @@ -5,6 +5,6 @@ RPI:: Raspberry Pi Main board:: The main board is the PCB on the bottom of the puzzle box, this communicates with the puzzles and the bomb Puzzle box hub:: The puzzle box hub communicates with the puzzle box and the bomb, as well as helps with configuring them -SID:: security identifiers -game operator:: person who organizes a puzzle box play session +SID:: Security identifiers +game operator:: Person who organizes a puzzle box play session -- cgit v1.2.3 From 13b5f07326adde72f4e72bbb3b61d75eb643cf52 Mon Sep 17 00:00:00 2001 From: ThomasintAnker Date: Sat, 15 Jun 2024 17:34:56 +0200 Subject: finished project state --- docs/handover.adoc | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/docs/handover.adoc b/docs/handover.adoc index 94896e3..91fc03c 100644 --- a/docs/handover.adoc +++ b/docs/handover.adoc @@ -10,14 +10,26 @@ a software framework which can be used to implement new puzzles and to make the development process of these puzzles easier. == Project State -The current project state is as follows: No new hardware has been designed +The current project state is as follows: No new hardware has been designed or developed this year. The software was completely revised, now consisting of a -main controller, and multiple puzzle modules. The main controller (a RPI Pico W) -can interact with the different puzzle modules using an I^2^C bus. +a puzzle bus driver, a main controller, a simple CLI application, and two puzzle +modules. Namely the puzzle modules 'Vault' and 'Neotrellis', both using an arduino +as the controller. The main controller (a RPI Pico W) can interact with the +different puzzle modules using an I^2^C bus. The I^2^C bus has been configured to +be a multi-master I^2^C bus. allowing the puzzle modules and the main controller +to send and recieve messages on their own. The main controller is able to find +new puzzle modules on startup, and does not check for new modules afterwards. A +simple CLI application has been developed, which can communicate with the main +controller through a tcp connection and simple commands. == What Went Wrong +Vorige week hadden Elwin en Thomas wat moeite met het werkend krijgen van de multi-master I2C driver voor de Raspberry Pi Pico, en na wat rond puzzelen bleek dit een hardware limitatie van de RP2040 te zijn. De Atmega328P (van de Arduino) heeft de TWI-interface met ondersteuning voor I2C multi-master waarbij deze tegelijkertijd nog steeds adresseerbaar is als I2C slave. Dit kan de RP2040 niet, dus heb ik afgelopen maandag een workaround geïmplementeerd in de puzzel bus driver voor de RP2040. +Nu Lars uit onze groep is hebben we besloten zijn puzzel module te laten liggen. Door de slechte communicatie weten wij nu niet wat er mis is met deze puzzel module, en we zien het nu als een te groot risico om hier nu nog tijd in te steken. +Omdat ik nu beide Pico's thuis heb kunnen Elwin en Thomas momenteel weinig aan de software doen. Dit had heel makkelijk opgelost kunnen worden als ik meer dan 2 Pico's had laten bestellen, en dit zal ook zeker meegenomen worden in het overdrachtsdocument. + == Recommendations +Start creating prototypes as fast as possible, kijk naar de documentatie maar verifieer alles op het laagste niveau Voor de volgende jaren: maak zo snel mogelijk prototypes, laat zien dat *iets* werkt @@ -32,4 +44,7 @@ Maak een duidelijke waarschuwing" rpi heeft programmable io modules, mogelijk via deze omweg rp2040 wel als MULTIMASTER met slave adresseerbaar - rp2040 kan alleen 7-bit adressen hebben + +Momenteel verwijs ik in het overdrachtsdocument naar https://media.pipeframe.xyz/puzzlebox; + include::share/footer.adoc[] -- cgit v1.2.3 From 9635fb2e56cdb319f5fd80ea5973412295e18cd8 Mon Sep 17 00:00:00 2001 From: ThomasintAnker Date: Sat, 15 Jun 2024 18:45:47 +0200 Subject: Finished challenges --- docs/handover.adoc | 69 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 17 deletions(-) diff --git a/docs/handover.adoc b/docs/handover.adoc index 91fc03c..905c826 100644 --- a/docs/handover.adoc +++ b/docs/handover.adoc @@ -1,7 +1,7 @@ :document: Handover include::share/meta.adoc[] -=== A Note Before Reading +== A Note Before Reading The team of year 2023-2024 consisted of only software students, meaning no hardware was developed in this year. We were tasked with simplifying the software to the point where it would only have to be ported into the new hardware, @@ -9,6 +9,9 @@ which was designed in the year 2022-2023. The goal of this year would be to crea a software framework which can be used to implement new puzzles and to make the development process of these puzzles easier. +At the moment of writing, the documentation of previous years can be found at the +following link: 'https://media.pipeframe.xyz/puzzlebox'. + == Project State The current project state is as follows: No new hardware has been designed or developed this year. The software was completely revised, now consisting of a @@ -22,29 +25,61 @@ new puzzle modules on startup, and does not check for new modules afterwards. A simple CLI application has been developed, which can communicate with the main controller through a tcp connection and simple commands. -== What Went Wrong -Vorige week hadden Elwin en Thomas wat moeite met het werkend krijgen van de multi-master I2C driver voor de Raspberry Pi Pico, en na wat rond puzzelen bleek dit een hardware limitatie van de RP2040 te zijn. De Atmega328P (van de Arduino) heeft de TWI-interface met ondersteuning voor I2C multi-master waarbij deze tegelijkertijd nog steeds adresseerbaar is als I2C slave. Dit kan de RP2040 niet, dus heb ik afgelopen maandag een workaround geïmplementeerd in de puzzel bus driver voor de RP2040. -Nu Lars uit onze groep is hebben we besloten zijn puzzel module te laten liggen. Door de slechte communicatie weten wij nu niet wat er mis is met deze puzzel module, en we zien het nu als een te groot risico om hier nu nog tijd in te steken. -Omdat ik nu beide Pico's thuis heb kunnen Elwin en Thomas momenteel weinig aan de software doen. Dit had heel makkelijk opgelost kunnen worden als ik meer dan 2 Pico's had laten bestellen, en dit zal ook zeker meegenomen worden in het overdrachtsdocument. +In short: A puzzle bus driver has been implemented, to allow for communication +between the main controller and the puzzle modules. A CLI application was developed +which connects with the main controller to monitor/edit the gamestate. And the +software for the puzzle modules 'Vault' and 'Neotrellis' is in the product state. +The hardware design can be derived from the year 2022-2023, and you can derive the +game rules from the year 2020-2021. -== Recommendations -Start creating prototypes as fast as possible, -kijk naar de documentatie maar verifieer alles op het laagste niveau +== Challenges +There were a multitude of different challenges we had to face before getting to a +working product. Most of these have been documented here, and it is highly recommended +to have a look at this before development. -Voor de volgende jaren: maak zo snel mogelijk prototypes, laat zien dat *iets* werkt +=== Misconceptions +Make sure to know what you are developing and do some research beforehand, to make +sure you have the complete picture about what you are using. Sounds stupid, but it +happened for multiple project attempts, and cause time-loss. This also includes +documentation of previous years: go through the documentation and verify it on the +lowest possible level for the same reason as previously mentioned. -ER MOET ONDERZOCHT WORDEN NAAR MULTIMASTER CONTROLLERS DIE OOK ALS SLAVE KUNNEN WORDEN GEADDRESSEERD (INTENS MOEILIJK TE VINDEN) +=== I^2^C +I^2^C is easy to implement but also easy to underestimate, this project requires a +multi-master structure as communication is otherwise too complicated compared to +other means of communication. -i2c MOET, arbitration moet, Atmega328p zou geschikt zijn voor losse puzzelmodules +For I^2^C on hardware level: make sure to use pull-up resistors, 2k2 if bus is on +100khz, as it is otherwise impossible to use I^2^C due to incorrect messages. This +is also recommended for controllers which are connected to the I^2^C bus. Make sure +to use I^2^C arbitration to check if the bus is not busy when writing to it, as +this will result in complictions in the communication. --- -Maak een duidelijke waarschuwing" -- ga er niet van uit dat je het al weet, doe ff wat low level research over de onderwerpen +The RPI Pico W (RP2040) does not support multi-master to the point of being able to +receive messages from other multi-masters as a slave while being configured as master. +Everything else about the I^2^C bus works, but due to this limitation a workaround has +been implemented to be able to continue using the RPI Pico W. Under ideal circumstances +a different controller could be found which does support this, but one was not found at +the time of writing. To simplify; a controller is needed which supports multi-master +while being able to be addressed as a slave-type controller. -rpi heeft programmable io modules, mogelijk via deze omweg rp2040 wel als MULTIMASTER met slave adresseerbaar -- rp2040 kan alleen 7-bit adressen hebben +=== Available Hardware/SDKs +When choosing or using specific chips/sdks make sure it is available for (at least) +a few years. This makes it easier for the next project team to use the same chips/sdks +instead of having to find new ones because the previous project team did not think about +this possibility. This also includes having enough sdks for multiple people to program +using the same setup, eg. the RPI Pico W requires another RPI Pico W to be debugged. +Effectively requiring the project team to have at least 4 RPI Pico Ws to be able to develop +in the same environment (if there are 2 software students). -Momenteel verwijs ik in het overdrachtsdocument naar https://media.pipeframe.xyz/puzzlebox; +== Recommendations +* Start creating prototypes as fast as possible, this benefits the project in the long run, +as you have already shown that certain parts of the project are already working and only +need to be integrated. +* The Atmega328P-chip is sufficient for the puzzle modules as it has enough IO and I^2^C +connectivity possibilities. +* The RPI Pico W has programmable IO modules, making it possible to create an I^2^C driver +that allows multi-master communication while still being addressable as a slave. include::share/footer.adoc[] -- cgit v1.2.3 From d6dca7f40a51a40217ca9ec600e17527d9962a8b Mon Sep 17 00:00:00 2001 From: ThomasintAnker Date: Mon, 17 Jun 2024 13:07:02 +0200 Subject: Changed title of recommendations to proffesional english --- docs/handover.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/handover.adoc b/docs/handover.adoc index 905c826..280cb7e 100644 --- a/docs/handover.adoc +++ b/docs/handover.adoc @@ -73,7 +73,7 @@ using the same setup, eg. the RPI Pico W requires another RPI Pico W to be debug Effectively requiring the project team to have at least 4 RPI Pico Ws to be able to develop in the same environment (if there are 2 software students). -== Recommendations +== Imperatives * Start creating prototypes as fast as possible, this benefits the project in the long run, as you have already shown that certain parts of the project are already working and only need to be integrated. -- cgit v1.2.3 From 245fde65808ce902064ab438296f04f691d007e7 Mon Sep 17 00:00:00 2001 From: ThomasintAnker Date: Tue, 18 Jun 2024 16:10:04 +0200 Subject: Added clang formatting --- .clang-format | 19 +++++++++++++++++++ .clang-tidy | 25 +++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 .clang-format create mode 100644 .clang-tidy diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..3266955 --- /dev/null +++ b/.clang-format @@ -0,0 +1,19 @@ +--- +AccessModifierOffset: -4 +AlignConsecutiveAssignments: true +AllowShortIfStatementsOnASingleLine: AllIfsAndElse +AllowShortLoopsOnASingleLine: true +BasedOnStyle: LLVM +BreakBeforeBraces: Attach +ColumnLimit: 180 +EmptyLineBeforeAccessModifier: Always +IndentAccessModifiers: false +IndentCaseLabels: true +IndentWidth: 4 +Language: Cpp +Standard: Cpp11 +TabWidth: 4 +UseTab: Always +... + +# vim: ft=yaml \ No newline at end of file diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..7a8470a --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,25 @@ +Checks: '-*,readability-identifier-naming' +CheckOptions: + - { key: readability-identifier-naming.EnumCase, value: lower_case } + - { key: readability-identifier-naming.EnumPrefix, value: hh_e_ } + - { key: readability-identifier-naming.GlobalFunctionCase, value: lower_case } + - { key: readability-identifier-naming.GlobalFunctionPrefix, value: hh_ } + - { key: readability-identifier-naming.ClassCase, value: CamelCase } + - { key: readability-identifier-naming.ClassPrefix, value: hh } + - { key: readability-identifier-naming.ClassMethodCase, value: lower_case } + - { key: readability-identifier-naming.ClassMethodPrefix, value: '' } + - { key: readability-identifier-naming.ClassMemberCase, value: lower_case } + - { key: readability-identifier-naming.ClassMemberPrefix, value: '' } + - { key: readability-identifier-naming.GlobalConstantCase, value: UPPER_CASE } + - { key: readability-identifier-naming.GlobalConstantIgnoredRegexp, value: _.* } + - { key: readability-identifier-naming.GlobalConstantPrefix, value: HH_ } + - { key: readability-identifier-naming.GlobalVariableCase, value: lower_case } + - { key: readability-identifier-naming.GlobalVariableIgnoredRegexp, value: _.* } + - { key: readability-identifier-naming.GlobalVariablePrefix, value: g_hh_ } + - { key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE } + - { key: readability-identifier-naming.MacroDefinitionIgnoredRegexp, value: _.* } + - { key: readability-identifier-naming.MacroDefinitionPrefix, value: HH_ } + - { key: readability-identifier-naming.StructCase, value: lower_case } + - { key: readability-identifier-naming.StructPrefix, value: hh_s_ } + +# vim: ft=yaml -- cgit v1.2.3 From b45b5d04daa29fcdd456233a931dcbb5b287769f Mon Sep 17 00:00:00 2001 From: ThomasintAnker Date: Tue, 18 Jun 2024 16:19:20 +0200 Subject: Finished handover --- docs/handover.adoc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/handover.adoc b/docs/handover.adoc index 280cb7e..e25a864 100644 --- a/docs/handover.adoc +++ b/docs/handover.adoc @@ -73,6 +73,10 @@ using the same setup, eg. the RPI Pico W requires another RPI Pico W to be debug Effectively requiring the project team to have at least 4 RPI Pico Ws to be able to develop in the same environment (if there are 2 software students). +=== Arduino +Allocating memory using 'realloc' on arduino is not possible, which also denies usage of +the 'mpack_writer_init_growable' + == Imperatives * Start creating prototypes as fast as possible, this benefits the project in the long run, as you have already shown that certain parts of the project are already working and only -- cgit v1.2.3 From ae5dd8e93411e01b087a840d33b0c970cac4a523 Mon Sep 17 00:00:00 2001 From: ThomasintAnker Date: Tue, 18 Jun 2024 16:29:06 +0200 Subject: fixed multi doc handover --- docs/handover.adoc | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/docs/handover.adoc b/docs/handover.adoc index a3fd880..8c86e1b 100644 --- a/docs/handover.adoc +++ b/docs/handover.adoc @@ -85,7 +85,14 @@ communication.] | Software | Thomas in 't Anker | Software |=== -== Resources + +== A Note Before Reading +The team of year 2023-2024 consisted of only software students, meaning no +hardware was developed in this year. We were tasked with simplifying the +software to the point where it would only have to be ported into the new hardware, +which was designed in the year 2022-2023. The goal of this year would be to create +a software framework which can be used to implement new puzzles and to make the +development process of these puzzles easier. Previous years' groups have put their predecessor's documents inside their own project folder, which has resulted in what we called the 'Russian doll folder @@ -97,31 +104,6 @@ require credentials to log in. Please note that this is very much unofficial, and is not managed or endorsed by Avans. <> is the contact for removal or transfer of these files. -== Recommendations - -- The 22-23 design document already mentions that the application of the I^2^C - bus is in a multi-master configuration, but does not mention that this only - works when pull-up resistors are used on the SCL and SDA lines. The pull-up - resistors are required, as omitting them makes the bus arbitration process - very inconsistent which causes frames to be dropped entirely. - -include::share/footer.adoc[] - - -:document: Handover -include::share/meta.adoc[] - -== A Note Before Reading -The team of year 2023-2024 consisted of only software students, meaning no -hardware was developed in this year. We were tasked with simplifying the -software to the point where it would only have to be ported into the new hardware, -which was designed in the year 2022-2023. The goal of this year would be to create -a software framework which can be used to implement new puzzles and to make the -development process of these puzzles easier. - -At the moment of writing, the documentation of previous years can be found at the -following link: 'https://media.pipeframe.xyz/puzzlebox'. - == Project State The current project state is as follows: No new hardware has been designed or developed this year. The software was completely revised, now consisting of a @@ -195,5 +177,10 @@ need to be integrated. connectivity possibilities. * The RPI Pico W has programmable IO modules, making it possible to create an I^2^C driver that allows multi-master communication while still being addressable as a slave. +* The 22-23 design document already mentions that the application of the I^2^C +bus is in a multi-master configuration, but does not mention that this only +works when pull-up resistors are used on the SCL and SDA lines. The pull-up +resistors are required, as omitting them makes the bus arbitration process +very inconsistent which causes frames to be dropped entirely. include::share/footer.adoc[] -- cgit v1.2.3