Initial commit

master
Jonas Arnold 3 years ago
commit 1f76bebaa9
  1. 1
      .gitignore
  2. 64
      .vscode/c_cpp_properties.json
  3. 10
      .vscode/extensions.json
  4. 44
      .vscode/launch.json
  5. 39
      include/README
  6. 182
      lib/McuLib/McuLib.h
  7. 241
      lib/McuLib/McuLibconfig.h
  8. 2951
      lib/McuLib/McuUtility.c
  9. 1520
      lib/McuLib/McuUtility.h
  10. 15
      lib/McuLib/McuUtilityconfig.h
  11. 46
      lib/README
  12. 15
      platformio.ini
  13. 138
      src/main.cpp
  14. 11
      test/README

1
.gitignore vendored

@ -0,0 +1 @@
.pio

@ -0,0 +1,64 @@
//
// !!! WARNING !!! AUTO-GENERATED FILE!
// PLEASE DO NOT MODIFY IT AND USE "platformio.ini":
// https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags
//
{
"configurations": [
{
"name": "PlatformIO",
"includePath": [
"c:/work/source/BAT/Arduino_RawHidDevice/include",
"c:/work/source/BAT/Arduino_RawHidDevice/src",
"c:/work/source/BAT/Arduino_RawHidDevice/lib/McuLib",
"c:/work/source/BAT/Arduino_RawHidDevice/.pio/libdeps/micro/HID-Project/src",
"C:/Users/jonas/.platformio/packages/framework-arduino-avr/libraries/HID/src",
"C:/Users/jonas/.platformio/packages/framework-arduino-avr/cores/arduino",
"C:/Users/jonas/.platformio/packages/framework-arduino-avr/variants/micro",
"C:/Users/jonas/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src",
"C:/Users/jonas/.platformio/packages/framework-arduino-avr/libraries/SPI/src",
"C:/Users/jonas/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src",
"C:/Users/jonas/.platformio/packages/framework-arduino-avr/libraries/Wire/src",
""
],
"browse": {
"limitSymbolsToIncludedHeaders": true,
"path": [
"c:/work/source/BAT/Arduino_RawHidDevice/include",
"c:/work/source/BAT/Arduino_RawHidDevice/src",
"c:/work/source/BAT/Arduino_RawHidDevice/lib/McuLib",
"c:/work/source/BAT/Arduino_RawHidDevice/.pio/libdeps/micro/HID-Project/src",
"C:/Users/jonas/.platformio/packages/framework-arduino-avr/libraries/HID/src",
"C:/Users/jonas/.platformio/packages/framework-arduino-avr/cores/arduino",
"C:/Users/jonas/.platformio/packages/framework-arduino-avr/variants/micro",
"C:/Users/jonas/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src",
"C:/Users/jonas/.platformio/packages/framework-arduino-avr/libraries/SPI/src",
"C:/Users/jonas/.platformio/packages/framework-arduino-avr/libraries/SoftwareSerial/src",
"C:/Users/jonas/.platformio/packages/framework-arduino-avr/libraries/Wire/src",
""
]
},
"defines": [
"PLATFORMIO=60106",
"ARDUINO_AVR_MICRO",
"F_CPU=16000000L",
"ARDUINO_ARCH_AVR",
"ARDUINO=10808",
"USB_VID=0x2341",
"USB_PID=0x8037",
"USB_PRODUCT=\"Arduino Micro\"",
"USB_MANUFACTURER=\"Arduino\"",
"__AVR_ATmega32U4__",
""
],
"cStandard": "c11",
"cppStandard": "c++11",
"compilerPath": "C:/Users/jonas/.platformio/packages/toolchain-atmelavr/bin/avr-gcc.exe",
"compilerArgs": [
"-mmcu=atmega32u4",
""
]
}
],
"version": 4
}

@ -0,0 +1,10 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}

@ -0,0 +1,44 @@
// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY
//
// PIO Unified Debugger
//
// Documentation: https://docs.platformio.org/page/plus/debugging.html
// Configuration: https://docs.platformio.org/page/projectconf/section_env_debug.html
{
"version": "0.2.0",
"configurations": [
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug",
"executable": "c:/work/source/BAT/Arduino_RawHidDevice/.pio/build/micro/firmware.elf",
"projectEnvName": "micro",
"toolchainBinDir": "C:/Users/jonas/.platformio/packages/toolchain-atmelavr/bin",
"internalConsoleOptions": "openOnSessionStart",
"preLaunchTask": {
"type": "PlatformIO",
"task": "Pre-Debug"
}
},
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug (skip Pre-Debug)",
"executable": "c:/work/source/BAT/Arduino_RawHidDevice/.pio/build/micro/firmware.elf",
"projectEnvName": "micro",
"toolchainBinDir": "C:/Users/jonas/.platformio/packages/toolchain-atmelavr/bin",
"internalConsoleOptions": "openOnSessionStart"
},
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug (without uploading)",
"executable": "c:/work/source/BAT/Arduino_RawHidDevice/.pio/build/micro/firmware.elf",
"projectEnvName": "micro",
"toolchainBinDir": "C:/Users/jonas/.platformio/packages/toolchain-atmelavr/bin",
"internalConsoleOptions": "openOnSessionStart",
"loadMode": "manual"
}
]
}

@ -0,0 +1,39 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

@ -0,0 +1,182 @@
/* ###################################################################
** This component module is generated by Processor Expert. Do not modify it.
** Filename : McuLib.h
** Project : FRDM-K64F_Generator
** Processor : MK64FN1M0VLL12
** Component : McuLibConfig
** Version : Component 01.016, Driver 01.00, CPU db: 3.00.000
** Compiler : GNU C Compiler
** Date/Time : 2021-05-13, 11:07, # CodeGen: 738
** Abstract :
** Configures the drivers for various SDKs and APIs used.
** Settings :
** Component name : McuLib
** SDK : Processor Expert
** Contents :
** Init - void McuLib_Init(void);
** Deinit - void McuLib_Deinit(void);
**
** * Copyright (c) 2016-2021, Erich Styger
** * Web: https://mcuoneclipse.com
** * SourceForge: https://sourceforge.net/projects/mcuoneclipse
** * Git: https://github.com/ErichStyger/McuOnEclipse_PEx
** * All rights reserved.
** *
** * Redistribution and use in source and binary forms, with or without modification,
** * are permitted provided that the following conditions are met:
** *
** * - Redistributions of source code must retain the above copyright notice, this list
** * of conditions and the following disclaimer.
** *
** * - Redistributions in binary form must reproduce the above copyright notice, this
** * list of conditions and the following disclaimer in the documentation and/or
** * other materials provided with the distribution.
** *
** * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
** * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
** * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
** * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
** * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
** * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
** * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
** * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
** * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
** ###################################################################*/
/*!
** @file McuLib.h
** @version 01.00
** @brief
** Configures the drivers for various SDKs and APIs used.
*/
/*!
** @addtogroup McuLib_module McuLib module documentation
** @{
*/
#ifndef __McuLib_H
#define __McuLib_H
/* MODULE McuLib. */
#include "McuLibconfig.h" /* include configuration header file */
#ifdef __cplusplus
extern "C" {
#endif
/** IMPORTANT DEFINITIONS **/
#include <stdint.h> /* uint8_t, int16_t, ... */
#include <stdbool.h> /* bool, true, false, ... */
/* boolean values */
#ifndef FALSE
#define FALSE 0x00u
#endif
#ifndef TRUE
#define TRUE 0x01u
#endif
/* error codes */
#define ERR_OK 0x00U /*!< OK */
#define ERR_SPEED 0x01U /*!< This device does not work in the active speed mode. */
#define ERR_RANGE 0x02U /*!< Parameter out of range. */
#define ERR_VALUE 0x03U /*!< Parameter of incorrect value. */
#define ERR_OVERFLOW 0x04U /*!< Timer overflow. */
#define ERR_MATH 0x05U /*!< Overflow during evaluation. */
#define ERR_ENABLED 0x06U /*!< Device is enabled. */
#define ERR_DISABLED 0x07U /*!< Device is disabled. */
#define ERR_BUSY 0x08U /*!< Device is busy. */
#define ERR_NOTAVAIL 0x09U /*!< Requested value or method not available. */
#define ERR_RXEMPTY 0x0AU /*!< No data in receiver. */
#define ERR_TXFULL 0x0BU /*!< Transmitter is full. */
#define ERR_BUSOFF 0x0CU /*!< Bus not available. */
#define ERR_OVERRUN 0x0DU /*!< Overrun error is detected. */
#define ERR_FRAMING 0x0EU /*!< Framing error is detected. */
#define ERR_PARITY 0x0FU /*!< Parity error is detected. */
#define ERR_NOISE 0x10U /*!< Noise error is detected. */
#define ERR_IDLE 0x11U /*!< Idle error is detected. */
#define ERR_FAULT 0x12U /*!< Fault error is detected. */
#define ERR_BREAK 0x13U /*!< Break char is received during communication. */
#define ERR_CRC 0x14U /*!< CRC error is detected. */
#define ERR_ARBITR 0x15U /*!< A node losts arbitration. This error occurs if two nodes start transmission at the same time. */
#define ERR_PROTECT 0x16U /*!< Protection error is detected. */
#define ERR_UNDERFLOW 0x17U /*!< Underflow error is detected. */
#define ERR_UNDERRUN 0x18U /*!< Underrun error is detected. */
#define ERR_COMMON 0x19U /*!< Common error of a device. */
#define ERR_LINSYNC 0x1AU /*!< LIN synchronization error is detected. */
#define ERR_FAILED 0x1BU /*!< Requested functionality or process failed. */
#define ERR_QFULL 0x1CU /*!< Queue is full. */
#define ERR_PARAM_MASK 0x80U /*!< Invalid mask. */
#define ERR_PARAM_MODE 0x81U /*!< Invalid mode. */
#define ERR_PARAM_INDEX 0x82U /*!< Invalid index. */
#define ERR_PARAM_DATA 0x83U /*!< Invalid data. */
#define ERR_PARAM_SIZE 0x84U /*!< Invalid size. */
#define ERR_PARAM_VALUE 0x85U /*!< Invalid value. */
#define ERR_PARAM_RANGE 0x86U /*!< Invalid parameter's range or parameters' combination. */
#define ERR_PARAM_LOW_VALUE 0x87U /*!< Invalid value (LOW part). */
#define ERR_PARAM_HIGH_VALUE 0x88U /*!< Invalid value (HIGH part). */
#define ERR_PARAM_ADDRESS 0x89U /*!< Invalid address. */
#define ERR_PARAM_PARITY 0x8AU /*!< Invalid parity. */
#define ERR_PARAM_WIDTH 0x8BU /*!< Invalid width. */
#define ERR_PARAM_LENGTH 0x8CU /*!< Invalid length. */
#define ERR_PARAM_ADDRESS_TYPE 0x8DU /*!< Invalid address type. */
#define ERR_PARAM_COMMAND_TYPE 0x8EU /*!< Invalid command type. */
#define ERR_PARAM_COMMAND 0x8FU /*!< Invalid command. */
#define ERR_PARAM_RECIPIENT 0x90U /*!< Invalid recipient. */
#define ERR_PARAM_BUFFER_COUNT 0x91U /*!< Invalid buffer count. */
#define ERR_PARAM_ID 0x92U /*!< Invalid ID. */
#define ERR_PARAM_GROUP 0x93U /*!< Invalid group. */
#define ERR_PARAM_CHIP_SELECT 0x94U /*!< Invalid chip select. */
#define ERR_PARAM_ATTRIBUTE_SET 0x95U /*!< Invalid set of attributes. */
#define ERR_PARAM_SAMPLE_COUNT 0x96U /*!< Invalid sample count. */
#define ERR_PARAM_CONDITION 0x97U /*!< Invalid condition. */
#define ERR_PARAM_TICKS 0x98U /*!< Invalid ticks parameter. */
/* Other basic data types */
typedef signed char int8;
typedef signed short int int16;
typedef signed long int int32;
typedef unsigned char uint8;
typedef unsigned short int uint16;
typedef unsigned long int uint32;
void McuLib_Init(void);
/*
** ===================================================================
** Method : Init (component McuLibConfig)
**
** Description :
** Driver initialization method
** Parameters : None
** Returns : Nothing
** ===================================================================
*/
void McuLib_Deinit(void);
/*
** ===================================================================
** Method : Deinit (component McuLibConfig)
**
** Description :
** Driver deinitialization method
** Parameters : None
** Returns : Nothing
** ===================================================================
*/
/* END McuLib. */
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif
/* ifndef __McuLib_H */
/*!
** @}
*/

@ -0,0 +1,241 @@
/**
* \file
* \brief Configuration header file for McuLibConfig
* Copyright (c) 2020, Erich Styger
* SPDX-License-Identifier: BSD-3-Clause
*
* This header file is used to configure settings of the McuLibConfig module.
*/
#ifndef __McuLib_CONFIG_H
#define __McuLib_CONFIG_H
/* identification of CPU/core used. __CORTEX_M is defined in CMSIS-Core.
Otherwise CPU Family is set automatically by Processor Expert: detected: Kinetis (supported: "Kinetis", "S32K", "HCS08")
*/
#if defined(__CORTEX_M)
#define McuLib_CPU_IS_ARM_CORTEX_M (1)
#else
#define McuLib_CPU_IS_ARM_CORTEX_M (0)
#endif
#ifndef McuLib_CONFIG_CPU_IS_ARM_CORTEX_M
#define McuLib_CONFIG_CPU_IS_ARM_CORTEX_M (1 || McuLib_CPU_IS_ARM_CORTEX_M)
/*!< 1: ARM Cortex-M family, 0 otherwise */
#endif
#ifndef McuLib_CONFIG_CPU_IS_S32K
#define McuLib_CONFIG_CPU_IS_S32K (0 && McuLib_CONFIG_CPU_IS_ARM_CORTEX_M)
/*!< 1: NXP S32K CPU family, 0: otherwise */
#endif
#ifndef McuLib_CONFIG_CPU_IS_LPC
#define McuLib_CONFIG_CPU_IS_LPC (0 && McuLib_CONFIG_CPU_IS_ARM_CORTEX_M)
/*!< 1: NXP LPC CPU family, 0: otherwise */
#endif
#ifndef McuLib_CONFIG_CPU_IS_LPC55xx
#define McuLib_CONFIG_CPU_IS_LP55Cxx (0 && McuLib_CONFIG_CPU_IS_ARM_CORTEX_M && McuLib_CONFIG_CPU_IS_LPC)
/*!< 1: NXP LPC55xx CPU family, 0: otherwise */
#endif
#ifndef McuLib_CONFIG_CPU_IS_STM32
#define McuLib_CONFIG_CPU_IS_STM32 (0 && McuLib_CONFIG_CPU_IS_ARM_CORTEX_M)
/*!< 1: STM32 ARM Cortex CPU family, 0: otherwise */
#endif
#ifndef McuLib_CONFIG_CPU_IS_IMXRT
#define McuLib_CONFIG_CPU_IS_IMXRT (0 && McuLib_CONFIG_CPU_IS_ARM_CORTEX_M)
/*!< 1: NXP i.Mx RT CPU family, 0: otherwise */
#endif
#ifndef McuLib_CONFIG_CPU_IS_NORDIC_NRF
#define McuLib_CONFIG_CPU_IS_NORDIC_NRF (0 && McuLib_CONFIG_CPU_IS_ARM_CORTEX_M)
/*!< 1: Nordic nRF, 0: otherwise */
#endif
#ifndef McuLib_CONFIG_CPU_IS_HCS08
#define McuLib_CONFIG_CPU_IS_HCS08 (0 && !McuLib_CONFIG_CPU_IS_ARM_CORTEX_M)
/*!< 1: HCS08 CPU family, 0: otherwise */
#endif
#ifndef McuLib_CONFIG_CPU_IS_RISC_V
#define McuLib_CONFIG_CPU_IS_RISC_V (0 && !McuLib_CONFIG_CPU_IS_ARM_CORTEX_M)
/*!< 1: RISC-V CPU family, 0: otherwise */
#endif
#ifndef McuLib_CONFIG_CPU_IS_RISC_V_RV32M1_RI5CY
#define McuLib_CONFIG_CPU_IS_RISC_V_RV32M1_RI5CY (1 && McuLib_CONFIG_CPU_IS_RISC_V)
/*!< 1: VEGA Board: RISC-V RV32M1 RI5CY, 0: other core */
#endif
#ifndef McuLib_CONFIG_CPU_IS_ESP32
#ifndef __XTENSA__
#define __XTENSA__ 0
#endif
#define McuLib_CONFIG_CPU_IS_ESP32 (__XTENSA__)
/*!< 1: ESP32 CPU family, 0: otherwise. The ESP32 compiler defines __XTENSA__ with a value of 1 */
#endif
#ifndef McuLib_CONFIG_CPU_IS_RPxxxx
#define McuLib_CONFIG_CPU_IS_RPxxxx (0) /* Raspberry Pi RP, e.g. RP2040 */
#endif
#ifndef McuLib_CONFIG_CPU_IS_KINETIS
#define McuLib_CONFIG_CPU_IS_KINETIS (1 && McuLib_CONFIG_CPU_IS_ARM_CORTEX_M \
&& !(McuLib_CONFIG_CPU_IS_LPC) \
&& !(McuLib_CONFIG_CPU_IS_LPC55xx) \
&& !(McuLib_CONFIG_CPU_IS_IMXRT) \
&& !(McuLib_CONFIG_CPU_IS_STM32) \
&& !(McuLib_CONFIG_CPU_IS_NORDIC_NRF) \
&& !(McuLib_CONFIG_CPU_IS_S32K))
/*!< 1: NXP Kinetis CPU family, 0: otherwise */
#endif
/* define to identify the CPU variant better */
#define McuLib_CONFIG_CPU_VARIANT_DEFAULT (0)
#define McuLib_CONFIG_CPU_VARIANT_NXP_K02FN (1)
#define McuLib_CONFIG_CPU_VARIANT_NXP_K22FN (2)
#define McuLib_CONFIG_CPU_VARIANT_NXP_K22FX (3)
#define McuLib_CONFIG_CPU_VARIANT_NXP_KE02 (4)
#define McuLib_CONFIG_CPU_VARIANT_NXP_LPC804 (5)
#define McuLib_CONFIG_CPU_VARIANT_NXP_LPC845 (6)
#define McuLib_CONFIG_CPU_VARIANT_NXP_LPC54608 (7)
#define McuLib_CONFIG_CPU_VARIANT_NXP_LPC55S16 (8)
#define McuLib_CONFIG_CPU_VARIANT_NXP_LPC55S69 (9)
#define McuLib_CONFIG_CPU_VARIANT_NXP_IMXRT1064 (10)
#define McuLib_CONFIG_CPU_VARIANT_RP2040 (11)
#define McuLib_CONFIG_CPU_VARIANT_NXP_K64FN (12)
#ifndef McuLib_CONFIG_CPU_VARIANT
#define McuLib_CONFIG_CPU_VARIANT McuLib_CONFIG_CPU_VARIANT_DEFAULT
#endif
#if McuLib_CONFIG_CPU_IS_LPC && McuLib_CONFIG_CPU_VARIANT==McuLib_CONFIG_CPU_VARIANT_DEFAULT
#error "Please specify the LPC CPU variant used"
#endif
#ifndef McuLib_CONFIG_IS_KINETIS_KE
#define McuLib_CONFIG_IS_KINETIS_KE (McuLib_CONFIG_CPU_VARIANT==McuLib_CONFIG_CPU_VARIANT_NXP_KE02)
#endif
/* identification of Cortex-M core. __FPU_USED can be defined in CMSIS-Core */
#ifndef McuLib_CONFIG_CORTEX_M
#define McuLib_CONFIG_CORTEX_M (4)
/*!< 0: Cortex-M0, 3: M3, 4: M4, 7: M7, 33: M33, -1 otherwise */
#endif
#if (1 && !defined(McuLib_CONFIG_FPU_PRESENT) && McuLib_CONFIG_CORTEX_M!=0) || (defined(__FPU_PRESENT) && (__FPU_PRESENT==1)) /* __FPU_PRESENT can be defined in CMSIS-Core */
#define McuLib_CONFIG_FPU_PRESENT (1)
#else
#define McuLib_CONFIG_FPU_PRESENT (0)
#endif
/*!< 1: floating point unit present, 0: otherwise */
#if (1 && !defined(McuLib_CONFIG_FPU_USED) && McuLib_CONFIG_CORTEX_M!=0) || (defined(__FPU_USED) && (__FPU_USED==1)) /* __FPU_USED can be defined in CMSIS-Core */
#define McuLib_CONFIG_FPU_USED (1)
#else
#define McuLib_CONFIG_FPU_USED (0)
#endif
/*!< 1: using floating point unit, 0: otherwise */
/* macro for little and big endianess. ARM is little endian */
#define McuLib_CONFIG_CPU_IS_LITTLE_ENDIAN (McuLib_CONFIG_CPU_IS_ARM_CORTEX_M)
/* Identifiers used to identify the SDK */
#define McuLib_CONFIG_SDK_GENERIC (0)
/*!< using a generic API/SDK */
#define McuLib_CONFIG_SDK_PROCESSOR_EXPERT (1)
/*!< using Processor Expert SDK */
#define McuLib_CONFIG_SDK_KINETIS_1_3 (2)
/*!< using NXP Kinetis SDK V1.3 */
#define McuLib_CONFIG_SDK_KINETIS_2_0 (3)
/*!< using NXP Kinetis SDK V2.0 */
#define McuLib_CONFIG_SDK_MCUXPRESSO_2_0 (4)
/*!< using NXP MCUXpresso SDK V2.x, same as Kinetis SDK v2.0 */
#define McuLib_CONFIG_SDK_S32K (5)
/*!< SDK for S32K */
#define McuLib_CONFIG_SDK_NORDIC_NRF5 (6)
/*!< Nordic nRF5 SDK */
#define McuLib_CONFIG_SDK_RPI_PICO (7)
/*!< Raspberry Pi Pico SDK */
#ifndef McuLib_CONFIG_SDK_VERSION_MAJOR
#define McuLib_CONFIG_SDK_VERSION_MAJOR (2)
/*!< SDK major version number */
#endif
#ifndef McuLib_CONFIG_SDK_VERSION_MINOR
#define McuLib_CONFIG_SDK_VERSION_MINOR (5)
/*!< SDK minor version number */
#endif
#ifndef McuLib_CONFIG_SDK_VERSION_BUILD
#define McuLib_CONFIG_SDK_VERSION_BUILD (0)
/*!< SDK build version number */
#endif
#ifndef McuLib_CONFIG_SDK_VERSION
#define McuLib_CONFIG_SDK_VERSION (McuLib_CONFIG_SDK_VERSION_MAJOR*100)+(McuLib_CONFIG_SDK_VERSION_MINOR*10)+McuLib_CONFIG_SDK_VERSION_BUILD
/*!< Builds a single number with the SDK version (major, minor, build), e.g. 250 for 2.5.0 */
#endif
/* specify the SDK and API used */
#ifndef McuLib_CONFIG_SDK_VERSION_USED
#if McuLib_CONFIG_CPU_IS_ESP32
#define McuLib_CONFIG_SDK_VERSION_USED McuLib_CONFIG_SDK_GENERIC
/*!< identify the version of SDK/API used. For ESP32 we are using a generic SDK (actually the IDF one) */
#elif McuLib_CONFIG_CPU_IS_STM32
#define McuLib_CONFIG_SDK_VERSION_USED McuLib_CONFIG_SDK_GENERIC
/*!< identify the version of SDK/API used. For STM32 we are using a generic SDK (actually the CubeMX one) */
#else
#define McuLib_CONFIG_SDK_VERSION_USED McuLib_CONFIG_SDK_PROCESSOR_EXPERT
/*!< identify the version of SDK/API used */
#endif
#endif
/* ***************** Middleware Configuration *******************/
/* Configuration macro if FreeRTOS is used */
#ifndef McuLib_CONFIG_SDK_USE_FREERTOS
#define McuLib_CONFIG_SDK_USE_FREERTOS (1)
/*!< 1: Use FreeRTOS; 0: no FreeRTOS used */
#endif
/* FatFS */
#ifndef McuLib_CONFIG_SDK_USE_FAT_FS
#define McuLib_CONFIG_SDK_USE_FAT_FS (0)
/*!< 1: Use FatFS; 0: no FatFS used */
#endif
/* ***************************************************************/
/* special macro to identify a set of SDKs used */
#define McuLib_CONFIG_NXP_SDK_USED ( (McuLib_CONFIG_SDK_VERSION_USED==McuLib_CONFIG_SDK_KINETIS_1_3) \
|| (McuLib_CONFIG_SDK_VERSION_USED==McuLib_CONFIG_SDK_KINETIS_2_0) \
|| (McuLib_CONFIG_SDK_VERSION_USED==McuLib_CONFIG_SDK_MCUXPRESSO_2_0) \
|| (McuLib_CONFIG_SDK_VERSION_USED==McuLib_CONFIG_SDK_S32K) \
)
/*!< Using one of the Freescale/NXP SDKs */
#define McuLib_CONFIG_NXP_SDK_2_0_USED ( (McuLib_CONFIG_SDK_VERSION_USED==McuLib_CONFIG_SDK_KINETIS_2_0) \
|| (McuLib_CONFIG_SDK_VERSION_USED==McuLib_CONFIG_SDK_MCUXPRESSO_2_0) \
)
/*!< Using Freescale/NXP SDK V2.0 */
#define McuLib_CONFIG_PEX_SDK_USED (McuLib_CONFIG_SDK_VERSION_USED==McuLib_CONFIG_SDK_PROCESSOR_EXPERT)
/*!< Using Processor Expert API */
/* Compiler identification: */
#define McuLib_CONFIG_COMPILER_GNU (0)
#define McuLib_CONFIG_COMPILER_IAR (1)
#define McuLib_CONFIG_COMPILER_KEIL (2)
#define McuLib_CONFIG_COMPILER_HIWARE (3)
#define McuLib_CONFIG_COMPILER_METROWERKS (4)
#ifndef McuLib_CONFIG_COMPILER
#if defined(__GNUC__)
#define McuLib_CONFIG_COMPILER McuLib_CONFIG_COMPILER_GNU
#elif defined(__HIWARE__)
#define McuLib_CONFIG_COMPILER McuLib_CONFIG_COMPILER_HIWARE
#elif defined(__IAR_SYSTEMS_ICC__)
#define McuLib_CONFIG_COMPILER McuLib_CONFIG_COMPILER_IAR
#elif defined(__CC_ARM)
#define McuLib_CONFIG_COMPILER McuLib_CONFIG_COMPILER_KEIL
#elif defined(__MWERKS__)
#define McuLib_CONFIG_COMPILER McuLib_CONFIG_COMPILER_METROWERKS
#else
#warning "a compiler needs to be defined!"
#endif
#endif
#endif /* __McuLib_CONFIG_H */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,15 @@
/**
* \file
* \brief Configuration header file for Utility
* Copyright (c) 2020, Erich Styger
* SPDX-License-Identifier: BSD-3-Clause
*
* This header file is used to configure settings of the Utility module.
*/
#ifndef __McuUtility_CONFIG_H
#define __McuUtility_CONFIG_H
/* no configuration supported yet */
#endif /* __McuUtility_CONFIG_H */

@ -0,0 +1,46 @@
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html

@ -0,0 +1,15 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:micro]
platform = atmelavr
board = micro
framework = arduino
lib_deps = nicohood/HID-Project@^2.8.4

@ -0,0 +1,138 @@
/*
Copyright (c) 2014-2015 NicoHood
See the readme for credit to other people.
Advanced RawHID example
Shows how to send bytes via RawHID.
Press a button to send some example values.
Every received data is mirrored to the host via Serial.
See HID Project documentation for more information.
https://github.com/NicoHood/HID/wiki/RawHID-API
*/
#include "Arduino.h"
#include "HID-Project.h"
#include "McuUtility.h"
const int pinLed = 17;
bool ledState = true;
// Buffer to hold RawHID data.
// If host tries to send more data than this,
// it will respond with an error.
// If the data is not read until the host sends the next data
// it will also respond with an error and the data will be lost.
uint8_t rawhidData[255];
uint8_t sendMessageBuffer[60];
char receivedMessageBuffer[255];
uint8_t counter;
const char HELP_COMMAND_STRING[] = "help";
const char LED_COMMAND_STRING[] = "led toggle";
const char LED_COMMAND_RESPONSE[] = "LED was toggled.";
// Declarations
void UsbHidSendLine(unsigned char* str);
void setup() {
pinMode(pinLed, OUTPUT);
digitalWrite(pinLed, ledState);
Serial.begin(115200);
// Set the RawHID OUT report array.
// Feature reports are also (parallel) possible, see the other example for this.
RawHID.begin(rawhidData, sizeof(rawhidData));
}
void loop() {
// Check if there is new data from the RawHID device
int bytesAvailable = RawHID.available();
if (bytesAvailable)
{
Serial.print("Num bytes available: ");
Serial.print(bytesAvailable);
Serial.print('\n');
// prepare for reading
counter = 0;
// Mirror data via Serial
while (bytesAvailable--) {
char currentByte = (char)RawHID.read();
// save only if it is a printable character
if(currentByte >= 32 && currentByte <= 126)
{
receivedMessageBuffer[counter++] = currentByte;
}
}
// print read message
Serial.print("Received: '");
Serial.print((char*)receivedMessageBuffer);
Serial.print("'\n");
}
// check if the received command stated the LED command
if(McuUtility_strcmp(receivedMessageBuffer, LED_COMMAND_STRING)==0)
{
// toggle led
ledState = !ledState;
digitalWrite(pinLed, ledState == true ? HIGH : LOW);
// send response
McuUtility_strcpy((unsigned char*)sendMessageBuffer, sizeof(sendMessageBuffer), (unsigned char*)LED_COMMAND_RESPONSE);
RawHID.write(sendMessageBuffer, sizeof(sendMessageBuffer));
Serial.print("Sent: '");
Serial.print((char*)sendMessageBuffer);
Serial.print("'\n");
}
else if(McuUtility_strcmp(receivedMessageBuffer, HELP_COMMAND_STRING)==0)
{
// send response
UsbHidSendLine((unsigned char*)"--------------------------------------------\r\n");
UsbHidSendLine((unsigned char*)"------------ ARDUINO HID TEST APP ----------\r\n");
UsbHidSendLine((unsigned char*)"--------------------------------------------\r\n");
UsbHidSendLine((unsigned char*)"Test 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21X22X23X24 25 26 27 28 29 30 XX Test 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30\r\n");
UsbHidSendLine((unsigned char*)"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.\r\n");
UsbHidSendLine((unsigned char*)"--------------------------------------------\r\n");
//McuUtility_strcpy((unsigned char*)sendMessageBuffer, sizeof(sendMessageBuffer), );
//RawHID.write(sendMessageBuffer, sizeof(sendMessageBuffer));
//Serial.print("Sent: '");
//Serial.print((char*)sendMessageBuffer);
//Serial.print("'\n");
}
// clear buffer
memset(receivedMessageBuffer, '\0', sizeof(receivedMessageBuffer));
// Wait some minor time
delay(20);
}
void UsbHidSendLine(unsigned char* str)
{
if (str!=NULL) {
int32_t messageBytes = McuUtility_strlen((char*)str);
uint8_t bufferSize = sizeof(sendMessageBuffer);
Serial.print("Sending message with ");
Serial.print(messageBytes);
Serial.print(" bytes and buffer size ");
Serial.print(bufferSize);
Serial.print(": \n'''\n");
// split message in buffer Size amount
for(int byteNum = 0; messageBytes > 0; byteNum++){
memset(sendMessageBuffer, '\0', sizeof(sendMessageBuffer)); // clear send buffer
// copy part of message to send buffer. move pointer by buffer size to take the next part of the string.
McuUtility_strcpy((unsigned char*)sendMessageBuffer, sizeof(sendMessageBuffer), (unsigned char*)(str + bufferSize*byteNum));
RawHID.write(sendMessageBuffer, sizeof(sendMessageBuffer)); // write buffer
Serial.print((char*)sendMessageBuffer); // print
messageBytes -= bufferSize; // subtract bufferSize from message bytes
}
Serial.print("\n'''\n");
}
}

@ -0,0 +1,11 @@
This directory is intended for PlatformIO Test Runner and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PlatformIO Unit Testing:
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html
Loading…
Cancel
Save