Yuliya Smirnova
/
h7adc
stm32h7 udp server with adc
main.cpp
- Committer:
- yuliyasm
- Date:
- 2020-10-26
- Revision:
- 1:125ced0f8dd5
- Parent:
- 0:837bd71aa81c
File content as of revision 1:125ced0f8dd5:
#include "mbed.h" #include "EthernetInterface.h" #include "LWIPStack.h" #include "ADE7912/ADE7912.h" EthernetInterface net; DigitalOut led1(LED1); Thread thread; void UDP_thread() { printf("UDP Socket example\n"); net.set_network(SocketAddress("192.168.0.10"), SocketAddress("255.255.255.0"), SocketAddress("192.168.0.1")); if (0 != net.connect()) { printf("Error connecting\n"); } UDPSocket sock; sock.open(&net); sock.bind(55151); SocketAddress receive("192.168.0.1", 55151); for(;;) { char out_buffer[10] = "I am LED!"; // sock.recvfrom(&receive, &out_buffer, sizeof(out_buffer)); // printf(out_buffer); if (0 > sock.sendto(receive, out_buffer, sizeof(out_buffer))) { printf("Error sending data\n"); } printf(out_buffer); ThisThread::sleep_for(2000); } } int main() { struct ADE7912_Phase_Settings a_phase; a_phase.CS_pin = 10;//SPI1_CS_Pin; //a_phase.CS_port = SPI1_CS_GPIO_Port; a_phase.freq = F_8KHZ; a_phase.bandwidth = BW_2KHZ; thread.start(UDP_thread); while (true) { led1 = !led1; ThisThread::sleep_for(500); } }