Working communication.

This commit is contained in:
Ulysse Cura 2026-09-27 20:51:33 +02:00
parent e0e624f659
commit 93bb7cd524
6 changed files with 134 additions and 3 deletions

View File

@ -30,11 +30,23 @@ add_subdirectory(lib/Pico_I2C)
target_link_libraries(Pico_Master
pico_stdlib
Pico_I2C
pico_cyw43_arch_lwip_poll
)
target_link_libraries(Pico_Slave
pico_stdlib
Pico_I2C
pico_cyw43_arch_lwip_poll
)
# Includes
target_include_directories(Pico_Master PUBLIC
${CMAKE_CURRENT_LIST_DIR}/src/.
)
# Includes
target_include_directories(Pico_Slave PUBLIC
${CMAKE_CURRENT_LIST_DIR}/src/.
)
# Stdio configuration

View File

@ -1,3 +1,3 @@
# PicoW_UDP_Tests
# Pico_I2C_Tests
Test of the library PicoW_UDP_Lib.
Test of the library Pico_I2C_Lib.

@ -1 +1 @@
Subproject commit 2ec3b6816b2c863b03d3dceb4bb247dd48781ec5
Subproject commit 6013565e66cf5523d59cbbbac05785218da88ee3

92
src/lwipopts.h Normal file
View File

@ -0,0 +1,92 @@
#ifndef _LWIPOPTS_EXAMPLE_COMMONH_H
#define _LWIPOPTS_EXAMPLE_COMMONH_H
// Common settings used in most of the pico_w examples
// (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html for details)
// allow override in some examples
#ifndef NO_SYS
#define NO_SYS 1
#endif
// allow override in some examples
#ifndef LWIP_SOCKET
#define LWIP_SOCKET 0
#endif
#if PICO_CYW43_ARCH_POLL
#define MEM_LIBC_MALLOC 1
#else
// MEM_LIBC_MALLOC is incompatible with non polling versions
#define MEM_LIBC_MALLOC 0
#endif
#define MEM_ALIGNMENT 4
#ifndef MEM_SIZE
#define MEM_SIZE 4000
#endif
#define MEMP_NUM_TCP_SEG 32
#define MEMP_NUM_ARP_QUEUE 10
#define PBUF_POOL_SIZE 24
#define LWIP_ARP 1
#define LWIP_ETHERNET 1
#define LWIP_ICMP 1
#define LWIP_RAW 1
#define TCP_WND (8 * TCP_MSS)
#define TCP_MSS 1460
#define TCP_SND_BUF (8 * TCP_MSS)
#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1)) / (TCP_MSS))
#define LWIP_NETIF_STATUS_CALLBACK 1
#define LWIP_NETIF_LINK_CALLBACK 1
#define LWIP_NETIF_HOSTNAME 1
#define LWIP_NETCONN 0
#define MEM_STATS 0
#define SYS_STATS 0
#define MEMP_STATS 0
#define LINK_STATS 0
// #define ETH_PAD_SIZE 2
#define LWIP_CHKSUM_ALGORITHM 3
#define LWIP_DHCP 1
#define LWIP_IPV4 1
#define LWIP_TCP 1
#define LWIP_UDP 1
#define LWIP_DNS 1
#define LWIP_TCP_KEEPALIVE 1
#define LWIP_NETIF_TX_SINGLE_PBUF 1
#define DHCP_DOES_ARP_CHECK 0
#define LWIP_DHCP_DOES_ACD_CHECK 0
#ifndef NDEBUG
#define LWIP_DEBUG 1
#define LWIP_STATS 1
#define LWIP_STATS_DISPLAY 1
#endif
#define ETHARP_DEBUG LWIP_DBG_OFF
#define NETIF_DEBUG LWIP_DBG_OFF
#define PBUF_DEBUG LWIP_DBG_OFF
#define API_LIB_DEBUG LWIP_DBG_OFF
#define API_MSG_DEBUG LWIP_DBG_OFF
#define SOCKETS_DEBUG LWIP_DBG_OFF
#define ICMP_DEBUG LWIP_DBG_OFF
#define INET_DEBUG LWIP_DBG_OFF
#define IP_DEBUG LWIP_DBG_OFF
#define IP_REASS_DEBUG LWIP_DBG_OFF
#define RAW_DEBUG LWIP_DBG_OFF
#define MEM_DEBUG LWIP_DBG_OFF
#define MEMP_DEBUG LWIP_DBG_OFF
#define SYS_DEBUG LWIP_DBG_OFF
#define TCP_DEBUG LWIP_DBG_OFF
#define TCP_INPUT_DEBUG LWIP_DBG_OFF
#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
#define TCP_RTO_DEBUG LWIP_DBG_OFF
#define TCP_CWND_DEBUG LWIP_DBG_OFF
#define TCP_WND_DEBUG LWIP_DBG_OFF
#define TCP_FR_DEBUG LWIP_DBG_OFF
#define TCP_QLEN_DEBUG LWIP_DBG_OFF
#define TCP_RST_DEBUG LWIP_DBG_OFF
#define UDP_DEBUG LWIP_DBG_OFF
#define TCPIP_DEBUG LWIP_DBG_OFF
#define PPP_DEBUG LWIP_DBG_OFF
#define SLIP_DEBUG LWIP_DBG_OFF
#define DHCP_DEBUG LWIP_DBG_OFF
#endif /* __LWIPOPTS_H__ */

View File

@ -10,6 +10,10 @@ int main(void)
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, true);
i2c_master_t i2c_master;
init_i2c_master(&i2c_master, i2c0);
for(int i = 0; i < 3; i++)
{
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, false);
@ -30,11 +34,20 @@ int main(void)
led_state = !led_state;
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, led_state);
uint8_t data[2] = {0x00, led_state};
int ret = i2c_write_blocking(i2c_master.i2c_inst, 0x09, data, sizeof(data), false);
if(ret != sizeof(data))
{
printf("Error sending data : %d\n", ret);
}
}
tight_loop_contents();
}
exit_i2c_master(&i2c_master);
cyw43_arch_deinit();
return PICO_OK;

View File

@ -10,8 +10,22 @@ int main(void)
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, true);
i2c_slave_t i2c_slave;
init_i2c_slave(&i2c_slave, i2c0, 0x09);
for(int i = 0; i < 3; i++)
{
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, false);
sleep_ms(100);
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, true);
sleep_ms(100);
}
while(true)
{
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, i2c_slave.buffer[0]);
tight_loop_contents();
}