diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2019-02-28 17:04:22 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2019-02-28 17:04:22 -0500 |
commit | d6869d1ec4bd24cd2c3eafa534f0849b25ec5607 (patch) | |
tree | 79e54ed27b39c31864895535d11399708d5a45c0 /arduino/cores/nRF5/Arduino.h | |
parent | 614ee97bf3a2270c413527a7f35c54cbecd9e601 (diff) |
added basic code
Diffstat (limited to 'arduino/cores/nRF5/Arduino.h')
-rwxr-xr-x | arduino/cores/nRF5/Arduino.h | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/arduino/cores/nRF5/Arduino.h b/arduino/cores/nRF5/Arduino.h new file mode 100755 index 0000000..fb06853 --- /dev/null +++ b/arduino/cores/nRF5/Arduino.h @@ -0,0 +1,142 @@ +#ifndef Arduino_h +#define Arduino_h + +#include <stdbool.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> + +typedef bool boolean; +typedef uint8_t byte; +typedef uint16_t word; + +// some libraries and sketches depend on this AVR stuff, +// assuming Arduino.h or WProgram.h automatically includes it... + +#include "avr/pgmspace.h" +#include "avr/interrupt.h" + +#include "itoa.h" + +#ifdef __cplusplus +extern "C"{ +#endif // __cplusplus + +#include "wiring_constants.h" + +#define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L ) +#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) ) +#define microsecondsToClockCycles(a) ( (a) * (SystemCoreClock / 1000000L) ) + +void yield( void ) ; + +/* sketch */ +void setup( void ) ; +void loop( void ) ; + +void suspendLoop(void); +uint32_t setLoopStacksize(void); + +#include "WVariant.h" + +#ifdef __cplusplus +} // extern "C" +#endif + +// RTOS +#include "rtos.h" + +// The following headers are for C++ only compilation +#ifdef __cplusplus + #include "WCharacter.h" + #include "WString.h" + // #include "Tone.h" + #include "WMath.h" + #include "HardwareSerial.h" + #include "pulse.h" + #include "HardwarePWM.h" + #include "utility/SoftwareTimer.h" + + #include "Uart.h" +#endif + +#include "delay.h" +#include "binary.h" +#include "common_inc.h" +#include "utility/debug.h" +#include "utility/utilities.h" +#include "utility/AdaCallback.h" + +#ifdef NRF52840_XXAA + #include "tusb.h" + +#ifdef __cplusplus + #include "USBSerial.h" +#endif + +#endif + +// Include board variant +#include "variant.h" + +#include "wiring.h" +#include "wiring_digital.h" +#include "wiring_analog.h" +#include "wiring_shift.h" +#include "WInterrupts.h" + +// undefine stdlib's abs if encountered +#ifdef abs +#undef abs +#endif // abs + +#define min(a,b) ((a)<(b)?(a):(b)) +#define max(a,b) ((a)>(b)?(a):(b)) +#define abs(x) ((x)>0?(x):-(x)) +#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) +#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) +#define radians(deg) ((deg)*DEG_TO_RAD) +#define degrees(rad) ((rad)*RAD_TO_DEG) +#define sq(x) ((x)*(x)) + +#define interrupts() __enable_irq() +#define noInterrupts() __disable_irq() + +#define lowByte(w) ((uint8_t) ((w) & 0xff)) +#define highByte(w) ((uint8_t) ((w) >> 8)) + +#define bitRead(value, bit) (((value) >> (bit)) & 0x01ul) +#define bitSet(value, bit) ((value) |= (1UL << (bit))) +#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) +#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) + +#define bit(b) (1UL << (b)) + +#ifdef NRF_P1 +#define digitalPinToPort(P) ( (g_ADigitalPinMap[P] < 32) ? NRF_P0 : NRF_P1 ) +#else +#define digitalPinToPort(P) ( NRF_P0 ) +#endif + +#define digitalPinToBitMask(P) ( 1UL << ( g_ADigitalPinMap[P] < 32 ? g_ADigitalPinMap[P] : (g_ADigitalPinMap[P]-32) ) ) +//#define analogInPinToBit(P) ( ) +#define portOutputRegister(port) ( &(port->OUT) ) +#define portInputRegister(port) ( (volatile uint32_t*) &(port->IN) ) +#define portModeRegister(port) ( &(port->DIR) ) +#define digitalPinHasPWM(P) ( g_ADigitalPinMap[P] > 1 ) + +void rtos_idle_callback(void) ATTR_WEAK; +/* + * digitalPinToTimer(..) is AVR-specific and is not defined for nRF52 + * architecture. If you need to check if a pin supports PWM you must + * use digitalPinHasPWM(..). + * + * https://github.com/arduino/Arduino/issues/1833 + */ +// #define digitalPinToTimer(P) + +// Interrupts +#define digitalPinToInterrupt(P) ( P ) + +#endif // Arduino_h |