Siren
/
SIREN_MODULE
Programma Siren
Revision 0:2bd507b775d3, committed 2018-04-06
- Comitter:
- Wonderjack996
- Date:
- Fri Apr 06 10:57:42 2018 +0000
- Commit message:
- Programma Siren
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.gitignore Fri Apr 06 10:57:42 2018 +0000 @@ -0,0 +1,4 @@ +.build +.mbed +projectfiles +*.py*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.md Fri Apr 06 10:57:42 2018 +0000 @@ -0,0 +1,87 @@ +# Getting started with Blinky on mbed OS + +This guide reviews the steps required to get Blinky working on an mbed OS platform. + +Please install [mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli). + +## Import the example application + +From the command-line, import the example: + +``` +mbed import mbed-os-example-blinky +cd mbed-os-example-blinky +``` + +### Now compile + +Invoke `mbed compile`, and specify the name of your platform and your favorite toolchain (`GCC_ARM`, `ARM`, `IAR`). For example, for the ARM Compiler 5: + +``` +mbed compile -m K64F -t ARM +``` + +Your PC may take a few minutes to compile your code. At the end, you see the following result: + +``` +[snip] ++----------------------------+-------+-------+------+ +| Module | .text | .data | .bss | ++----------------------------+-------+-------+------+ +| Misc | 13939 | 24 | 1372 | +| core/hal | 16993 | 96 | 296 | +| core/rtos | 7384 | 92 | 4204 | +| features/FEATURE_IPV4 | 80 | 0 | 176 | +| frameworks/greentea-client | 1830 | 60 | 44 | +| frameworks/utest | 2392 | 512 | 292 | +| Subtotals | 42618 | 784 | 6384 | ++----------------------------+-------+-------+------+ +Allocated Heap: unknown +Allocated Stack: unknown +Total Static RAM memory (data + bss): 7168 bytes +Total RAM memory (data + bss + heap + stack): 7168 bytes +Total Flash memory (text + data + misc): 43402 bytes +Image: .\.build\K64F\ARM\mbed-os-example-blinky.bin +``` + +### Program your board + +1. Connect your mbed device to the computer over USB. +1. Copy the binary file to the mbed device. +1. Press the reset button to start the program. + +The LED on your platform turns on and off. + +## Export the project to Keil MDK, and debug your application + +From the command-line, run the following command: + +``` +mbed export -m K64F -i uvision +``` + +To debug the application: + +1. Start uVision. +1. Import the uVision project generated earlier. +1. Compile your application, and generate an `.axf` file. +1. Make sure uVision is configured to debug over CMSIS-DAP (From the Project menu > Options for Target '...' > Debug tab > Use CMSIS-DAP Debugger). +1. Set breakpoints, and start a debug session. + +![Image of uVision](img/uvision.png) + +## Troubleshooting + +1. Make sure `mbed-cli` is working correctly and its version is `>1.0.0` + + ``` + mbed --version + ``` + + If not, you can update it: + + ``` + pip install mbed-cli --upgrade + ``` + +2. If using Keil MDK, make sure you have a license installed. [MDK-Lite](http://www.keil.com/arm/mdk.asp) has a 32 KB restriction on code size. \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Apr 06 10:57:42 2018 +0000 @@ -0,0 +1,76 @@ +#include "mbed.h" +#include "TCPSocket.h" +#include "EthernetInterface.h" + +#define MY_DEFAULT_IP_ADDR "10.51.23." +#define MY_DEFAULT_MASK "255.255.255.0" +#define MY_DEFAULT_GATEWAY "10.51.23.254" + +#define MESSAGE_RUN "RUN" +#define MESSAGE_IDLE "IDLE" + +//new server windows 2012 ctosw00014.cto.st.com +#define SIREN_SERVER_NAME "10.51.37.30" +#define SIREN_SERVER_PORT 8897 + +#define LWIP_ICMP 1 +#define MEMP_NUM_SYS_TIMEOUT 16 + +#if defined(TARGET_ARCH_MAX) +#define CHECKSUM_GEN_ICMP 0 +#endif + +#if !CHECKSUM_GEN_ICMP + iecho->chksum = 0; +#endif + +DigitalIn bit0(D9); +DigitalIn bit1(D8); +DigitalIn bit2(D7); +DigitalIn bit3(D6); +DigitalIn bit4(D5); +DigitalIn bit5(D4); +DigitalIn bit6(D3); +DigitalIn bit7(D2); + +DigitalIn configurazione_rele(PB_11); //NO - 1, NC - 0 +DigitalIn rele_ventola(PB_10); +DigitalIn semaforo_1(PE_10); +DigitalIn semaforo_2(PE_12); +DigitalIn semaforo_3(PE_14); +DigitalIn semaforo_4(PE_15); +DigitalIn alimentazione(PE_7); + +EthernetInterface eth; +TCPSocket socket; + +int main() +{ + char ip_scheda[100]; + int val = (1*bit0.read())+(2*bit1.read())+(4*bit2.read())+(8*bit3.read())+(16*bit4.read())+(32*bit5.read())+(64*bit6.read())+(128*bit7.read()); + sprintf(ip_scheda, "%s%d",MY_DEFAULT_IP_ADDR,val); + + eth.set_network(ip_scheda, MY_DEFAULT_MASK, MY_DEFAULT_GATEWAY); + eth.connect(); + const char *ip = eth.get_ip_address(); + printf("IP address is: %s\n\r", ip ? ip : "No IP"); + + while(true) + printf("valore: %d\n\r", rele_ventola.read()); + + // Open a socket on the network interface, and create a TCP connection to mbed.org + socket.open(ð); + socket.connect(SIREN_SERVER_NAME, SIREN_SERVER_PORT); + + // Send a simple http request + char sbuffer[] = "alarm"; + int scount = socket.send(sbuffer, sizeof sbuffer); + printf("sent %d [%.*s]\r\n", scount, strstr(sbuffer, "\r\n")-sbuffer, sbuffer); + + // Close the socket to return its memory and bring down the network interface + socket.close(); + eth.disconnect(); + + printf("Done\n"); +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Fri Apr 06 10:57:42 2018 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#98ba8acb83cfc65f30a8a0771a27c71443ab093a