aboutsummaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/i2c.c8
-rw-r--r--main/i2c.h2
-rw-r--r--main/sock.c1
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 <hardware/i2c.h>
extern uint8_t found[MAX_SLAVES];