An example of usage of the X-NUCLEO-PLC01A1 Programmable Logic Controller Expansion Board.

Dependencies:   X_NUCLEO_PLC01A1

PLC with the X-NUCLEO-PLC01A1 Expansion Board

This application provides a simple example of usage of the X-NUCLEO-PLC01A1 Programmable Logic Controller Expansion Board.
It shows how to use one PLC connected to the board, driving the status of each output channels according to the status of each input channels.

Revision:
4:17b45bcd5b40
Parent:
2:bf16a2ba8662
Child:
5:321e4e37ba1c
--- a/main.cpp	Tue Feb 23 10:45:16 2016 +0000
+++ b/main.cpp	Tue Feb 23 13:00:04 2016 +0000
@@ -45,19 +45,8 @@
 
 /* Definitions ---------------------------------------------------------------*/
 
-#define SPI_MOSI D11
-#define SPI_MISO D12
-#define SPI_SCLK D13
-
-#define SPI_BITS 16
-
-#define SPI_CS1 D9
-#define SPI_CS2 D10
-
-#define OUT_EN D6
-
 /* Uncomment this for OUTPUT_CYCLING ENABLE */
-#define OUTPUT_CYCLING
+//#define OUTPUT_CYCLING
 
 
 /* Variables -----------------------------------------------------------------*/
@@ -126,11 +115,11 @@
     /*----- Initialization. -----*/
         
     /* Initializing SPI bus. */
-    SPI spi(SPI_MOSI, SPI_MISO, SPI_SCLK);
-    setup(spi, SPI_BITS);
+    SPI spi(X_NUCLEO_PLC01A1_PIN_SPI_MOSI, X_NUCLEO_PLC01A1_PIN_SPI_MISO, X_NUCLEO_PLC01A1_PIN_SPI_SCLK);
+    setup(spi, X_NUCLEO_PLC01A1_PIN_SPI_BITS);
 
     /* Initializing PLC IO Channels Component. */
-    PLC plc(SPI_CS1, SPI_CS2, OUT_EN, spi);
+    PLC plc(X_NUCLEO_PLC01A1_PIN_SPI_CS1, X_NUCLEO_PLC01A1_PIN_SPI_CS2, X_NUCLEO_PLC01A1_PIN_OUT_EN, spi);
 
     while(1) {
         plc.plcInput().SetReadStatus(1);