i broke it
This commit is contained in:
15
src/w5500.c
15
src/w5500.c
@@ -52,7 +52,9 @@ void callback_ip_assigned(void) {
|
||||
void callback_ip_conflict(void) { DEBUG_PRINT("Callback: IP conflict!\n"); }
|
||||
|
||||
void configure_network(void) {
|
||||
DEBUG_PRINT("===\n");
|
||||
DEBUG_PRINT("Starting network configuration...\n");
|
||||
DEBUG_PRINT("===\n");
|
||||
|
||||
// Setup chip select and SPI callbacks
|
||||
reg_wizchip_cs_cbfunc(spi_select, spi_unselect);
|
||||
@@ -61,8 +63,9 @@ void configure_network(void) {
|
||||
|
||||
uint8_t rx_tx_buff_sizes[] = {2, 2, 2, 2, 2, 2, 2, 2};
|
||||
wizchip_init(rx_tx_buff_sizes, rx_tx_buff_sizes);
|
||||
}
|
||||
|
||||
// Start DHCP process
|
||||
void configure_dhcp(void) {
|
||||
wiz_NetInfo net_info = {.mac = {0xEA, 0x11, 0x22, 0x33, 0x44, 0xEA},
|
||||
.dhcp = NETINFO_DHCP};
|
||||
setSHAR(net_info.mac);
|
||||
@@ -73,16 +76,14 @@ void configure_network(void) {
|
||||
callback_ip_conflict);
|
||||
|
||||
// Attempt to acquire an IP address using DHCP
|
||||
const uint32_t max_attempts = 1e5;
|
||||
|
||||
// todo: run in a loop by a timer or sth
|
||||
for (uint32_t attempt = 0; !ip_assigned && attempt < max_attempts;
|
||||
++attempt) {
|
||||
while (!ip_assigned) {
|
||||
DHCP_run();
|
||||
Delay_Ms(100);
|
||||
DEBUG_PRINT("DHCP_run()...\n");
|
||||
}
|
||||
|
||||
if (!ip_assigned) {
|
||||
DEBUG_PRINT("\r\nIP was not assigned :(\r\n");
|
||||
DEBUG_PRINT("\r\nIP was not assigned\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user