i broke it

This commit is contained in:
2024-10-14 02:13:05 +06:00
parent 480a4a1ca5
commit 7d33688e75
12 changed files with 112 additions and 70 deletions

View File

@@ -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;
}