diff --git a/.github/workflows/Continuous-integration.yml b/.github/workflows/Continuous-integration.yml new file mode 100644 index 0000000..7bafe89 --- /dev/null +++ b/.github/workflows/Continuous-integration.yml @@ -0,0 +1,70 @@ +name: X_NUCLEO_53L7A1 Continuous Integration +on: + push: + branches: + - main + paths-ignore: + - '*' + - '**.md' + - '**.txt' + pull_request: + paths-ignore: + - '*' + - '**.md' + - '**.txt' +jobs: + astyle_check: + runs-on: ubuntu-latest + name: AStyle check + steps: + # First of all, clone the repo using the checkout action. + - name: Checkout + uses: actions/checkout@main + + - name: Astyle check + id: Astyle + uses: stm32duino/actions/astyle-check@main + + # Use the output from the `Astyle` step + - name: Astyle Errors + if: failure() + run: | + cat ${{ steps.Astyle.outputs.astyle-result }} + exit 1 + codespell: + name: Check for spelling errors + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@main + + # See: https://github.com/codespell-project/actions-codespell/blob/master/README.md + - name: Spell check + uses: codespell-project/actions-codespell@master + with: + check_filenames: true + check_hidden: true + # In the event of a false positive, add the word in all lower case to this file: + ignore_words_file: ./extras/codespell-ignore-words-list.txt + lib_build: + runs-on: ubuntu-latest + name: Library compilation + steps: + + # First of all, clone the repo using the checkout action. + - name: Checkout + uses: actions/checkout@main + + - name: Compilation + id: compile + uses: stm32duino/actions/compile-examples@main + with: + board-pattern: "NUCLEO_L476RG" + libraries: "STM32duino VL53L7CX" + + # Use the output from the `Compilation` step + - name: Compilation Errors + if: failure() + run: | + cat ${{ steps.compile.outputs.compile-result }} + exit 1 diff --git a/README.md b/README.md index 89185dd..89926bf 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,11 @@ When the NFC module is started and ready, the message "Sytstem init done!" is di Next, the tag is written, we wait few seconds, we read the same tag and print it on the monitor window. You can test this application by connecting it with your smartphone. -On Android, donwload a NFC Tools. Then start the app, check if NFC is activated +On Android, download a NFC Tools. Then start the app, check if NFC is activated on your smartphone. Put your smartphone near the tag, you can read it. You can write a tag with this app. -* X_NUCLEO_NFC04A1_SimpleWrite: This application writes a NDEF message, containg a URI record, to the tag. +* X_NUCLEO_NFC04A1_SimpleWrite: This application writes a NDEF message, containing a URI record, to the tag. When the NFC module is started and ready, the message "System init done!" is displayed on the monitor window. Next, the tag is written with a URI. @@ -31,7 +31,7 @@ Next, the tag is written with a URI. You can test this application by tapping the tag with your smartphone. On Android, check if NFC is activated on your smartphone. Put your smartphone near the tag to read it. -The prefered Internet Browser is automatically opened with the provided URI. +The preferred Internet Browser is automatically opened with the provided URI. # Dependencies diff --git a/examples/X_NUCLEO_NFC04A1_HelloWorld/X_NUCLEO_NFC04A1_HelloWorld.ino b/examples/X_NUCLEO_NFC04A1_HelloWorld/X_NUCLEO_NFC04A1_HelloWorld.ino old mode 100644 new mode 100755 index ef91609..1f25f4f --- a/examples/X_NUCLEO_NFC04A1_HelloWorld/X_NUCLEO_NFC04A1_HelloWorld.ino +++ b/examples/X_NUCLEO_NFC04A1_HelloWorld/X_NUCLEO_NFC04A1_HelloWorld.ino @@ -53,7 +53,7 @@ all LED's blink. You can also use your smartphone to read/write a tag. - On Android, donwload a NFC Tools. Then start the app, check if NFC is activated + On Android, download a NFC Tools. Then start the app, check if NFC is activated on your smartphone. Put your smartphone near the tag, you can read it. You can write a tag with this app. ****************************************************************************** @@ -61,55 +61,58 @@ #include "x_nucleo_nfc04.h" +#define DEV_I2C Wire +X_Nucleo_NFC04 Nfc(12, -1, &DEV_I2C); + void setup() { const char uri_write_message[] = "st.com/st25"; // Uri message to write in the tag const char uri_write_protocol[] = URI_ID_0x01_STRING; // Uri protocol to write in the tag String uri_write = String(uri_write_protocol) + String(uri_write_message); String uri_read; - if (X_Nucleo_Nfc04.begin()) { + if (Nfc.begin()) { while (1) { - X_Nucleo_Nfc04.ledOn(GREEN_LED); + Nfc.ledOn(GREEN_LED); delay(100); - X_Nucleo_Nfc04.ledOff(GREEN_LED); + Nfc.ledOff(GREEN_LED); delay(100); } } - X_Nucleo_Nfc04.ledOn(GREEN_LED); + Nfc.ledOn(GREEN_LED); - if (X_Nucleo_Nfc04.writeURI(uri_write_protocol, uri_write_message, "")) { + if (Nfc.writeURI(uri_write_protocol, uri_write_message, "")) { while (1) { - X_Nucleo_Nfc04.ledOn(BLUE_LED); + Nfc.ledOn(BLUE_LED); delay(100); - X_Nucleo_Nfc04.ledOff(BLUE_LED); + Nfc.ledOff(BLUE_LED); delay(100); } } - X_Nucleo_Nfc04.ledOn(BLUE_LED); + Nfc.ledOn(BLUE_LED); delay(100); - if (X_Nucleo_Nfc04.readURI(&uri_read)) { + if (Nfc.readURI(&uri_read)) { while (1) { - X_Nucleo_Nfc04.ledOn(YELLOW_LED); + Nfc.ledOn(YELLOW_LED); delay(100); - X_Nucleo_Nfc04.ledOff(YELLOW_LED); + Nfc.ledOff(YELLOW_LED); delay(100); } } - X_Nucleo_Nfc04.ledOn(YELLOW_LED); + Nfc.ledOn(YELLOW_LED); if (strcmp(uri_read.c_str(), uri_write.c_str()) != 0) { while (1) { - X_Nucleo_Nfc04.ledOn(GREEN_LED); - X_Nucleo_Nfc04.ledOn(BLUE_LED); - X_Nucleo_Nfc04.ledOn(YELLOW_LED); + Nfc.ledOn(GREEN_LED); + Nfc.ledOn(BLUE_LED); + Nfc.ledOn(YELLOW_LED); delay(100); - X_Nucleo_Nfc04.ledOff(GREEN_LED); - X_Nucleo_Nfc04.ledOff(BLUE_LED); - X_Nucleo_Nfc04.ledOff(YELLOW_LED); + Nfc.ledOff(GREEN_LED); + Nfc.ledOff(BLUE_LED); + Nfc.ledOff(YELLOW_LED); delay(100); } } @@ -117,4 +120,4 @@ void setup() { void loop() { //empty loop -} \ No newline at end of file +} diff --git a/examples/X_NUCLEO_NFC04A1_SimpleWrite/X_NUCLEO_NFC04A1_SimpleWrite.ino b/examples/X_NUCLEO_NFC04A1_SimpleWrite/X_NUCLEO_NFC04A1_SimpleWrite.ino old mode 100644 new mode 100755 index 7aa6895..ff9dc5f --- a/examples/X_NUCLEO_NFC04A1_SimpleWrite/X_NUCLEO_NFC04A1_SimpleWrite.ino +++ b/examples/X_NUCLEO_NFC04A1_SimpleWrite/X_NUCLEO_NFC04A1_SimpleWrite.ino @@ -53,13 +53,15 @@ You can use your smartphone to read the tag. On Android, check if NFC is activated on your smartphone. Put your smartphone near the tag to natively read it. - The prefered Internet Browser is automatically opened with the provided URI. + The preferred Internet Browser is automatically opened with the provided URI. ****************************************************************************** */ #include "x_nucleo_nfc04.h" #define SerialPort Serial +#define DEV_I2C Wire +X_Nucleo_NFC04 Nfc(12, -1, &DEV_I2C); void setup() { const char uri_write_message[] = "st.com/st25"; // Uri message to write in the tag @@ -69,23 +71,23 @@ void setup() { // Initialize serial for output. SerialPort.begin(115200); - if (X_Nucleo_Nfc04.begin() == 0) { + if (Nfc.begin() == 0) { SerialPort.println("System Init done!"); - X_Nucleo_Nfc04.ledOn(GREEN_LED); + Nfc.ledOn(GREEN_LED); } else { SerialPort.println("System Init failed!"); while (1); } - if (X_Nucleo_Nfc04.writeURI(uri_write_protocol, uri_write_message, "")) { + if (Nfc.writeURI(uri_write_protocol, uri_write_message, "")) { SerialPort.println("Write failed!"); while (1); } - X_Nucleo_Nfc04.ledOn(BLUE_LED); + Nfc.ledOn(BLUE_LED); } void loop() { //empty loop -} \ No newline at end of file +} diff --git a/extras/codespell-ignore-words-list.txt b/extras/codespell-ignore-words-list.txt new file mode 100644 index 0000000..ae11f32 --- /dev/null +++ b/extras/codespell-ignore-words-list.txt @@ -0,0 +1 @@ +msbuid diff --git a/library.properties b/library.properties index a1e81da..8f0a7aa 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=STM32duino X-NUCLEO-NFC04A1 -version=1.1.1 +version=2.0.0 author=STMicroelectronics maintainer=stm32duino sentence=Allows controlling the ST X-NUCLEO-NFC04A1 expansion board diff --git a/src/BSP/x_nucleo_nfc04a1.cpp b/src/BSP/x_nucleo_nfc04a1.cpp deleted file mode 100644 index a388ccd..0000000 --- a/src/BSP/x_nucleo_nfc04a1.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/** - ****************************************************************************** - * @file x_nucleo_nfc04a1.c - * @author MMY Application Team - * @version $Revision: 3351 $ - * @date $Date: 2017-01-25 17:28:08 +0100 (Wed, 25 Jan 2017) $ - * @brief This file provides nfc04a1 specific functions - ****************************************************************************** - * @attention - * - *

© COPYRIGHT 2017 STMicroelectronics

- * - * Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.st.com/myliberty - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, - * AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "Arduino.h" -#include "x_nucleo_nfc04a1.h" - -/** @addtogroup BSP - * @{ - */ - -/** @defgroup X_NUCLEO_NFC04A1 - * @{ - */ -/* Private typedef -----------------------------------------------------------*/ -/* Private defines -----------------------------------------------------------*/ -/* Private macros ------------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ -/* Global variables ----------------------------------------------------------*/ -/** @defgroup X_NUCLEO_NFC04A1_Global_Variables - * @{ - */ -uint8_t NFC04A1_Led[3] = { 5, 4, 2}; - -/** - * @} - */ - -/* Private function prototypes -----------------------------------------------*/ -/* Functions Definition ------------------------------------------------------*/ -/** @defgroup X_NUCLEO_NFC04A1_Public_Functions - * @{ - */ - -/** - * @brief This function initialize the GPIO to manage the Leds - * @brief through GPIO - * @param None - * @retval None - */ -void NFC04A1_LED_Init(void) -{ - for (uint16_t i = 0; i < sizeof(NFC04A1_Led); i++) { - pinMode(NFC04A1_Led[i], OUTPUT); - } -} - -/** - * @brief DeInit LEDs. - * @param Led: LED to be de-init. - * @note Led DeInit does not disable the GPIO clock nor disable the Mfx - */ -void NFC04A1_LED_DeInit(NFC04A1_Led_E /*led*/) -{ - -} - -/** - * @brief This function light on selected Led - * @param led : Led to be lit on - * @retval None - */ -void NFC04A1_LED_ON(const NFC04A1_Led_E led) -{ - digitalWrite(NFC04A1_Led[led], HIGH); -} - -/** - * @brief This function light off selected Led - * @param led : Led to be lit off - * @retval None - */ -void NFC04A1_LED_OFF(const NFC04A1_Led_E led) -{ - digitalWrite(NFC04A1_Led[led], LOW); -} - -/** - * @brief Toggles the selected LED - * @param led : Specifies the Led to be toggled - * @retval None - */ -void NFC04A1_LED_Toggle(const NFC04A1_Led_E led) -{ - digitalWrite(NFC04A1_Led[led], !digitalRead(NFC04A1_Led[led])); -} - -/** - * @} - */ - - - -/** - * @} - */ - -/** - * @} - */ - -/******************* (C) COPYRIGHT 2017 STMicroelectronics *****END OF FILE****/ diff --git a/src/BSP/x_nucleo_nfc04a1.h b/src/BSP/x_nucleo_nfc04a1.h deleted file mode 100644 index 3110bb6..0000000 --- a/src/BSP/x_nucleo_nfc04a1.h +++ /dev/null @@ -1,100 +0,0 @@ -/** - ****************************************************************************** - * @file x_nucleo_nfc04a1.h - * @author MMY Application Team - * @version $Revision: 3351 $ - * @date $Date: 2017-01-25 17:28:08 +0100 (Wed, 25 Jan 2017) $ - * @brief This file contains definitions for the x_nucleo_nfc04a1.c - * board specific functions. - ****************************************************************************** - * @attention - * - *

© COPYRIGHT 2017 STMicroelectronics

- * - * Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License"); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.st.com/myliberty - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, - * AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __X_NUCLEO_NFC04A1_H -#define __X_NUCLEO_NFC04A1_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** @addtogroup BSP - * @{ - */ - -/** @addtogroup X_NUCLEO_NFC04A1 - * @{ - */ - -/* Exported types ------------------------------------------------------------*/ -/** @defgroup X_NUCLEO_NFC04A1_Exported_Types - * @{ - */ -/** - * @brief NFC04A1 Led enumerator definition - */ -typedef enum { - GREEN_LED = 0, - BLUE_LED, - YELLOW_LED -} NFC04A1_Led_E; - -/** - * @brief NFC04A1 Led structure definition - */ - -typedef struct { - uint16_t NFC04A1_LED_PIN; -} NFC04A1_Led_TypeDef; - -/** - * @} - */ -/* Exported constants --------------------------------------------------------*/ -/* External variables --------------------------------------------------------*/ -/* Exported macro ------------------------------------------------------------*/ -/* Exported functions ------------------------------------------------------- */ -/** @defgroup ST25DV_NUCLEO_Exported_Functions - * @{ - */ -void NFC04A1_LED_Init(void); -void NFC04A1_LED_DeInit(NFC04A1_Led_E led); -void NFC04A1_LED_ON(const NFC04A1_Led_E led); -void NFC04A1_LED_OFF(const NFC04A1_Led_E led); -void NFC04A1_LED_Toggle(const NFC04A1_Led_E led); -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif -#endif /* __X_NUCLEO_NFC04A1_H */ - -/******************* (C) COPYRIGHT 2017 STMicroelectronics *****END OF FILE****/ diff --git a/src/x_nucleo_nfc04.cpp b/src/x_nucleo_nfc04.cpp old mode 100644 new mode 100755 index 7f1c077..2e48c41 --- a/src/x_nucleo_nfc04.cpp +++ b/src/x_nucleo_nfc04.cpp @@ -1,15 +1,6 @@ #include "x_nucleo_nfc04.h" #include "Arduino.h" -extern sCCFileInfo CCFileStruct; - -// make this instance available in the sketch -X_Nucleo_NFC04 X_Nucleo_Nfc04; - -X_Nucleo_NFC04::X_Nucleo_NFC04(void) -{ - -} int X_Nucleo_NFC04::begin() { int ret = 0; @@ -22,7 +13,8 @@ int X_Nucleo_NFC04::begin() ledOn(YELLOW_LED); delay(300); - ret = st25dv.begin(12, 7); // gpo, lpd + ret = ST25DV::begin(); + if (ret != ST25DV_OK) { return ret; } @@ -45,3 +37,30 @@ void X_Nucleo_NFC04::ledOff(int led) { NFC04A1_LED_OFF((NFC04A1_Led_E) led); } + +void X_Nucleo_NFC04::NFC04A1_LED_Init(void) +{ + for (uint16_t i = 0; i < sizeof(NFC04A1_Led); i++) { + pinMode(NFC04A1_Led[i], OUTPUT); + } +} + +void X_Nucleo_NFC04::NFC04A1_LED_DeInit(void) +{ + +} + +void X_Nucleo_NFC04::NFC04A1_LED_ON(const NFC04A1_Led_E led) +{ + digitalWrite(NFC04A1_Led[led], HIGH); +} + +void X_Nucleo_NFC04::NFC04A1_LED_OFF(const NFC04A1_Led_E led) +{ + digitalWrite(NFC04A1_Led[led], LOW); +} + +void X_Nucleo_NFC04::NFC04A1_LED_Toggle(const NFC04A1_Led_E led) +{ + digitalWrite(NFC04A1_Led[led], !digitalRead(NFC04A1_Led[led])); +} diff --git a/src/x_nucleo_nfc04.h b/src/x_nucleo_nfc04.h old mode 100644 new mode 100755 index 0b1ef39..1d0a5c7 --- a/src/x_nucleo_nfc04.h +++ b/src/x_nucleo_nfc04.h @@ -1,17 +1,38 @@ #ifndef _X_NUCLEO_NFC04_H_ #define _X_NUCLEO_NFC04_H_ - #include "ST25DVSensor.h" -#include "BSP/x_nucleo_nfc04a1.h" + +/** + * @brief NFC04A1 Led enumerator definition + */ +typedef enum { + GREEN_LED = 0, + BLUE_LED, + YELLOW_LED +} NFC04A1_Led_E; + +/** + * @brief NFC04A1 Led structure definition + */ + +typedef struct { + uint16_t NFC04A1_LED_PIN; +} NFC04A1_Led_TypeDef; class X_Nucleo_NFC04 : public ST25DV { public: - X_Nucleo_NFC04(void); + X_Nucleo_NFC04(int32_t gpo, int32_t lpd, TwoWire *i2c, Stream *serial = NULL) : ST25DV(gpo, lpd, i2c, serial) {} int begin(); void ledOn(int led); void ledOff(int led); + void NFC04A1_LED_Init(void); + void NFC04A1_LED_DeInit(void); + void NFC04A1_LED_ON(const NFC04A1_Led_E led); + void NFC04A1_LED_OFF(const NFC04A1_Led_E led); + void NFC04A1_LED_Toggle(const NFC04A1_Led_E led); + private: + sCCFileInfo CCFileStruct; + uint8_t NFC04A1_Led[3] = { 5, 4, 2}; }; -extern X_Nucleo_NFC04 X_Nucleo_Nfc04; - -#endif \ No newline at end of file +#endif