Commit 12aad1e9 authored by Christopher Reis's avatar Christopher Reis

Working on ethernet server thread

parent 098a6b88
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<breakpoints/>
\ No newline at end of file
......@@ -694,10 +694,12 @@
<File name="headers/mbed/Ticker.h" path="mbed/Ticker.h" type="1"/>
<File name="headers/mbed/can_api.h" path="mbed/can_api.h" type="1"/>
<File name="sources/mbed-dsp/cmsis_dsp/FilteringFunctions/arm_correlate_fast_opt_q15.c" path="mbed-dsp/cmsis_dsp/FilteringFunctions/arm_correlate_fast_opt_q15.c" type="1"/>
<File name="headers/threads.h" path="threads.h" type="1"/>
<File name="headers/mbed-rtos/rtx/TARGET_CORTEX_M/rt_Time.h" path="mbed-rtos/rtx/TARGET_CORTEX_M/rt_Time.h" type="1"/>
<File name="headers/mbed/us_ticker_api.h" path="mbed/us_ticker_api.h" type="1"/>
<File name="sources/mbed-dsp/cmsis_dsp/FilteringFunctions/arm_conv_partial_f32.c" path="mbed-dsp/cmsis_dsp/FilteringFunctions/arm_conv_partial_f32.c" type="1"/>
<File name="sources/mbed-dsp/cmsis_dsp/ComplexMathFunctions/arm_cmplx_mag_squared_q31.c" path="mbed-dsp/cmsis_dsp/ComplexMathFunctions/arm_cmplx_mag_squared_q31.c" type="1"/>
<File name="headers/helper.h" path="helper.h" type="1"/>
<File name="sources/mbed-dsp/cmsis_dsp/MatrixFunctions/arm_mat_sub_q31.c" path="mbed-dsp/cmsis_dsp/MatrixFunctions/arm_mat_sub_q31.c" type="1"/>
<File name="sources/WIZnet_Library/WIZnetInterface/WIZnetInterface.cpp" path="WIZnet_Library/WIZnetInterface/WIZnetInterface.cpp" type="1"/>
<File name="headers/mbed-dsp/dsp/FIR_f32.h" path="mbed-dsp/dsp/FIR_f32.h" type="1"/>
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -22,9 +22,9 @@
#include "mbed.h"
#include "mbed_debug.h"
#define USE_W5500
//#define USE_W5500
//#define USE_W5200
//#define USE_W5100
#define USE_W5100
#if defined(USE_W5500)
#include "W5500.h"
......
#include "WIZnetInterface.h"
#include "stm32f4xx_hal_iwdg.h"
IWDG_HandleTypeDef hiwdg; //Watchdog timer
int ret;
void watchdog_init(void){
hiwdg.Instance = IWDG;
hiwdg.Init.Prescaler = IWDG_PRESCALER_256;
hiwdg.Init.Reload = 1350; //10 seconds
HAL_IWDG_Init(&hiwdg);
}
void watchdog_start(void){
HAL_IWDG_Start(&hiwdg);
}
void watchdog_refresh(void){
HAL_IWDG_Refresh(&hiwdg);
}
void watchdog_status(void){
switch (HAL_IWDG_GetState(&hiwdg)){
case HAL_IWDG_STATE_RESET:
pc.printf("IWDG not yet initialized or disabled\r\n");
break;
case HAL_IWDG_STATE_READY:
pc.printf("IWDG initialized and ready for use\r\n");
break;
case HAL_IWDG_STATE_BUSY:
pc.printf("IWDG internal process is ongoing\r\n");
break;
case HAL_IWDG_STATE_TIMEOUT:
pc.printf("IWDG timeout state\r\n");
break;
case HAL_IWDG_STATE_ERROR:
pc.printf("IWDG error state\r\n");
break;
default:
pc.printf("Unknown state\n\r");
}
}
void f_ethernet_init()
{
watchdog_refresh();
uint8_t mac[]={0x90,0xa2,0xDa,0x0d,0x42,0xe0};
// mbed_mac_address((char *)mac);
pc.printf("\n\r\t####Starting Ethernet Server#### \n\r");
wait(1.0);
ret = eth.init(mac);
if(!ret)
{
pc.printf("Initialized, MAC= %s\n\r",eth.getMACAddress());
}
else
{
pc.printf("Communication Failure ... Restart devices ...\n\r");
}
pc.printf("Connecting...\r\n");
ret = eth.connect();
if(!ret)
{
pc.printf("Connection Established!\n\n\r");
wait(1);
pc.printf("IP=%s\n\rMASK=%s\n\rGW=%s\n\r",eth.getIPAddress(), eth.getNetworkMask(), eth.getGateway());
}
else
{
pc.printf("Communication Failure ... Restart devices ...\n\r");
}
}
void f_server_init(TCPSocketServer server, int port)
{
server.bind(port);
server.listen();
}
#include "mbed.h"
#include "rtos.h"
DigitalOut led1(PA_0);
DigitalOut led2(PA_1);
void led2_thread(void const *args) {
while (true) {
led2 = !led2;
Thread::wait(1000);
}
}
#include "WIZnetInterface.h"
Serial pc(SERIAL_TX,SERIAL_RX);
WIZnetInterface eth(SPI_MOSI, SPI_MISO, SPI_SCK,SPI_CS,PB_4); // spi, cs, reset
TCPSocketServer TCP_high;
TCPSocketServer TCP_low;
TCPSocketConnection client_h;
TCPSocketConnection client_l;
DigitalOut led1(PA_0, 0);
DigitalOut led2(PA_1, 0);
#include "helper.h"
#include "threads.h"
int main() {
Thread thread(led2_thread);
watchdog_init();
watchdog_status();
watchdog_start();
f_ethernet_init();
Thread thread1(t_led_blink);
Thread thread2(t_led_blink2);
while (true) {
led1 = !led1;
Thread::wait(500);
}
}
#include "rtos.h"
Mutex sdcard;
void t_led_blink(void const *args) {
while (true) {
watchdog_refresh();
led2 = !led2;
Thread::wait(1000);
}
}
void t_led_blink2(void const *args) {
while (true) {
watchdog_refresh();
led1 = !led1;
Thread::wait(500);
}
}
void t_server_high(void const *args) {
while (true) {
watchdog_refresh();
int acc = TCP_high.accept();
}
}
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