Commit 292db2df authored by Martin Vítek's avatar Martin Vítek

Add stack initialization

parent b5619b36
......@@ -96,7 +96,7 @@ void NixieClock::get_mac()
eeprom.read_EUI(mac);
char buffer[200];
sprintf(buffer, "Obtained MAC: %02X %02X %02X %02X %02X %02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
sprintf(buffer, "Obtained MAC: %02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
debug.info(buffer);
}
......
......@@ -19,6 +19,7 @@ NixieStack stack(eth);
NixieStack::NixieStack(ENC28J60& eth): eth(eth),
mac(0),
ip(0),
gateway(0),
link_is_up(false),
arp(mac, ip),
rx_buffer(),
......@@ -26,6 +27,11 @@ NixieStack::NixieStack(ENC28J60& eth): eth(eth),
{
}
void NixieStack::init()
{
eth.init(mac.mac);
}
void NixieStack::set_MAC(const uint8_t (&mac)[6])
{
this->mac.set(mac);
......@@ -36,6 +42,11 @@ void NixieStack::set_IP(const uint8_t (&ip)[4])
this->ip.set(ip);
}
void NixieStack::set_gateway(const uint8_t (&ip)[4])
{
this->gateway.set(ip);
}
void NixieStack::check_link()
{
if (eth.flag_link_changed)
......
......@@ -20,6 +20,7 @@ class NixieStack
MAC mac;
IP ip;
IP gateway;
bool link_is_up;
......@@ -31,9 +32,12 @@ class NixieStack
public:
NixieStack(ENC28J60& eth);
void init();
void set_MAC(const uint8_t (&mac)[6]);
void set_IP(const uint8_t (&ip)[4]);
void set_gateway(const uint8_t (&ip)[4]);
void check_link();
......
......@@ -58,17 +58,27 @@ int main(void)
//Enable external interrupts from buttons
sys.init_eic();
//Init buttons
button_hour.init();
button_min.init();
//Init timer for counting time (1ms increment)
tim.init();
//Init ADC
adc.init();
//Init SPI
spi.init();
//Init UART - 500 000baud, 8N1
uart.init();
//nixie.display.init();
//nixie.separator.init();
//boost.init();
boost.disable();
uart.init();
eth.init(MAC({0x54, 0x10, 0xEC, 0x20, 0xE5, 0xBD}));
......@@ -76,8 +86,21 @@ int main(void)
uart.send("Martin Vitek - 2017\n\r\n\r");
eth.print_device_info();
nixie.get_mac();
//Set-up MAC address for stack
uint8_t eeprom_mac[6];
eeprom.read_EUI(eeprom_mac);
stack.set_MAC(eeprom_mac);
//Set-up IPv4 address
stack.set_IP({192, 168, 1, 2});
//Set-up gateway address
stack.set_gateway({192, 168, 1, 1});
//Init network stack and ENC28J60
stack.init();
stack.test_tx();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment