text stringlengths 1 24.5M |
|---|
#ifndef TEENSY4_CURRENTSENSE_MCU_DEF
#define TEENSY4_CURRENTSENSE_MCU_DEF
#include "../../hardware_api.h"
#include "../../../common/foc_utils.h"
// if defined
// - Teensy 4.0
// - Teensy 4.1
#if defined(__arm__) && defined(CORE_TEENSY) && ( defined(__IMXRT1062__) || defined(ARDUINO_TEENSY40) || defined(ARDUINO_TE... |
#include "../../hardware_api.h"
#if defined(__arm__) && defined(CORE_TEENSY)
#define _ADC_VOLTAGE 3.3f
#define _ADC_RESOLUTION 1024.0f
// function reading an ADC value and returning the read voltage
void* _configureADCInline(const void* driver_params, const int pinA,const int pinB,const int pinC){
_UNUSED(driver_... |
#include "BLDCDriver3PWM.h"
BLDCDriver3PWM::BLDCDriver3PWM(int phA, int phB, int phC, int en1, int en2, int en3){
// Pin initialization
pwmA = phA;
pwmB = phB;
pwmC = phC;
// enable_pin pin
enableA_pin = en1;
enableB_pin = en2;
enableC_pin = en3;
// default power-supply value
voltage_power_supply... |
#ifndef BLDCDriver3PWM_h
#define BLDCDriver3PWM_h
#include "../common/base_classes/BLDCDriver.h"
#include "../common/foc_utils.h"
#include "../common/time_utils.h"
#include "../common/defaults.h"
#include "hardware_api.h"
/**
3 pwm bldc driver class
*/
class BLDCDriver3PWM: public BLDCDriver
{
public:
/**
... |
#include "BLDCDriver6PWM.h"
BLDCDriver6PWM::BLDCDriver6PWM(int phA_h,int phA_l,int phB_h,int phB_l,int phC_h,int phC_l, int en){
// Pin initialization
pwmA_h = phA_h;
pwmB_h = phB_h;
pwmC_h = phC_h;
pwmA_l = phA_l;
pwmB_l = phB_l;
pwmC_l = phC_l;
// enable_pin pin
enable_pin = en;
// default powe... |
#ifndef BLDCDriver6PWM_h
#define BLDCDriver6PWM_h
#include "../common/base_classes/BLDCDriver.h"
#include "../common/foc_utils.h"
#include "../common/time_utils.h"
#include "../common/defaults.h"
#include "hardware_api.h"
/**
6 pwm bldc driver class
*/
class BLDCDriver6PWM: public BLDCDriver
{
public:
/**
... |
#ifndef HARDWARE_UTILS_DRIVER_H
#define HARDWARE_UTILS_DRIVER_H
#include "../common/foc_utils.h"
#include "../common/time_utils.h"
#include "../communication/SimpleFOCDebug.h"
#include "../common/base_classes/BLDCDriver.h"
// these defines determine the polarity of the PWM output. Normally, the polarity is active-hi... |
#include "StepperDriver2PWM.h"
StepperDriver2PWM::StepperDriver2PWM(int _pwm1, int* _in1, int _pwm2, int* _in2, int en1, int en2){
// Pin initialization
pwm1 = _pwm1; // phase 1 pwm pin number
dir1a = _in1[0]; // phase 1 INA pin number
dir1b = _in1[1]; // phase 1 INB pin number
pwm2 = _pwm2; // phase 2 pwm p... |
#ifndef STEPPER_DRIVER_2PWM_h
#define STEPPER_DRIVER_2PWM_h
#include "../common/base_classes/StepperDriver.h"
#include "../common/foc_utils.h"
#include "../common/time_utils.h"
#include "../common/defaults.h"
#include "hardware_api.h"
/**
2 pwm stepper driver class
*/
class StepperDriver2PWM: public StepperDriver
{
... |
#include "StepperDriver4PWM.h"
StepperDriver4PWM::StepperDriver4PWM(int ph1A,int ph1B,int ph2A,int ph2B,int en1, int en2){
// Pin initialization
pwm1A = ph1A;
pwm1B = ph1B;
pwm2A = ph2A;
pwm2B = ph2B;
// enable_pin pin
enable_pin1 = en1;
enable_pin2 = en2;
// default power-supply value
voltage_po... |
#ifndef STEPPER_DRIVER_4PWM_h
#define STEPPER_DRIVER_4PWM_h
#include "../common/base_classes/StepperDriver.h"
#include "../common/foc_utils.h"
#include "../common/time_utils.h"
#include "../common/defaults.h"
#include "hardware_api.h"
/**
4 pwm stepper driver class
*/
class StepperDriver4PWM: public StepperDriver
{
... |
#include "../hardware_api.h"
#if defined(__arm__) && defined(__SAM3X8E__)
#pragma message("")
#pragma message("SimpleFOC: compiling for Arduino/Due")
#pragma message("")
#define _PWM_FREQUENCY 25000 // 25khz
#define _PWM_FREQUENCY_MAX 50000 // 50khz
#define _PWM_RES_MIN 255 // 50khz
// pwm frequency and max dut... |
#include "../hardware_api.h"
#if defined(ESP_H) && defined(ARDUINO_ARCH_ESP8266)
#pragma message("")
#pragma message("SimpleFOC: compiling for ESP8266")
#pragma message("")
#define _PWM_FREQUENCY 25000 // 25khz
#define _PWM_FREQUENCY_MAX 50000 // 50khz
// configure High PWM frequency
void _setHighFrequency(const... |
#include "../hardware_api.h"
// if the mcu doen't have defiend analogWrite
#if defined(ESP_H) && defined(ARDUINO_ARCH_ESP32) && !defined(analogWrite)
__attribute__((weak)) void analogWrite(uint8_t pin, int value){ };
#endif
// function setting the high pwm frequency to the supplied pin
// - Stepper motor - 1PWM se... |
#include "../hardware_api.h"
#if defined(NRF52_SERIES)
#pragma message("")
#pragma message("SimpleFOC: compiling for NRF52")
#pragma message("")
#define PWM_CLK (16000000)
#define PWM_FREQ (40000)
#define PWM_RESOLUTION (PWM_CLK/PWM_FREQ)
#define PWM_MAX_FREQ (62500)
#define DEAD_ZONE (250) // in ns
#define DEAD_T... |
#include "../hardware_api.h"
#if defined(TARGET_PORTENTA_H7) && false
#pragma message("")
#pragma message("SimpleFOC: compiling for Arduino/Portenta_H7")
#pragma message("")
#include "pwmout_api.h"
#include "pinDefinitions.h"
#include "platform/mbed_critical.h"
#include "platform/mbed_power_mgmt.h"
#include "plat... |
#include "../../hardware_api.h"
#if defined(__AVR_ATmega2560__) || defined(AVR_ATmega1280)
#pragma message("")
#pragma message("SimpleFOC: compiling for Arduino/ATmega2560 or Arduino/ATmega1280")
#pragma message("")
#define _PWM_FREQUENCY 32000
#define _PWM_FREQUENCY_MAX 32000
#define _PWM_FREQUENCY_MIN 4000
// s... |
#include "../../hardware_api.h"
#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega328PB__)
#pragma message("")
#pragma message("SimpleFOC: compiling for Arduino/ATmega328 ATmega168 ATmega328PB")
#pragma message("")
#define _PWM_FREQUENCY 32000
#define _PWM_FREQUENCY_MAX 32000
#defi... |
#include "../../hardware_api.h"
#if defined(__AVR_ATmega32U4__)
#pragma message("")
#pragma message("SimpleFOC: compiling for Arduino/ATmega32U4")
#pragma message("")
// set pwm frequency to 32KHz
void _pinHighFrequency(const int pin){
// High PWM frequency
// reference: http://r6500.blogspot.com/2014/12/fas... |
/*
* MCPWM in espressif v5.x has
* - 2x groups (units)
* each one has
* - 3 timers
* - 3 operators (that can be associated with any timer)
* which control a 2xPWM signals
* - 1x comparator + 1x generator per PWM signal
* Independent mode:
* ------------------
* 6 PWM independent signals per unit
* un... |
#ifndef ESP32_DRIVER_MCPWM_H
#define ESP32_DRIVER_MCPWM_H
#include "../../hardware_api.h"
#if defined(ESP_H) && defined(ARDUINO_ARCH_ESP32) && defined(SOC_MCPWM_SUPPORTED) && !defined(SIMPLEFOC_ESP32_USELEDC)
#include "driver/mcpwm_prelude.h"
#include "soc/mcpwm_reg.h"
#include "soc/mcpwm_struct.h"
#include "esp_idf... |
#include "../../hardware_api.h"
#if defined(ESP_H) && defined(ARDUINO_ARCH_ESP32) && ( !defined(SOC_MCPWM_SUPPORTED) || defined(SIMPLEFOC_ESP32_USELEDC) )
#pragma message("")
#pragma message("SimpleFOC: compiling for ESP32 LEDC driver")
#pragma message("")
#include "driver/ledc.h"
#include "esp_idf_version.h"
// ... |
#include "esp32_driver_mcpwm.h"
#if defined(ESP_H) && defined(ARDUINO_ARCH_ESP32) && defined(SOC_MCPWM_SUPPORTED) && !defined(SIMPLEFOC_ESP32_USELEDC)
#pragma message("")
#pragma message("SimpleFOC: compiling for ESP32 MCPWM driver")
#pragma message("")
int esp32_gpio_nr(int pin) {
#if defined(BOARD_HAS_PIN_REM... |
/*
* This is a private declaration of different MCPWM structures and types.
* It has been copied from: https://github.com/espressif/esp-idf/blob/v5.1.4/components/driver/mcpwm/mcpwm_private.h
*
* extracted by askuric 16.06.2024
*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX... |
#include "./renesas.h"
#if defined(ARDUINO_UNOR4_WIFI) || defined(ARDUINO_UNOR4_MINIMA)
#pragma message("")
#pragma message("SimpleFOC: compiling for Arduino/Renesas (UNO R4)")
#pragma message("")
#include "communication/SimpleFOCDebug.h"
#include "FspTimer.h"
#define GPT_OPEN ... |
#pragma once
#include "../../hardware_api.h"
#if defined(ARDUINO_UNOR4_WIFI) || defined(ARDUINO_UNOR4_MINIMA)
// uncomment to enable debug output from Renesas driver
// can set this as build-flag in Arduino IDE or PlatformIO
#define SIMPLEFOC_RENESAS_DEBUG
#define RENESAS_DEFAULT_PWM_FREQUENCY 24000
#define RENES... |
/**
* Support for the RP2040 MCU, as found on the Raspberry Pi Pico.
*/
#include "./rp2040_mcu.h"
#if defined(TARGET_RP2040) || defined(TARGET_RP2350)
#pragma message("")
#pragma message("SimpleFOC: compiling for RP2040/RP2350")
#pragma message("")
#if !defined(SIMPLEFOC_DEBUG_RP2040)
#define SIMPLEFOC_DEBUG_R... |
#pragma once
#include "Arduino.h"
#if defined(TARGET_RP2040) || defined(TARGET_RP2350)
typedef struct RP2040DriverParams {
int pins[6];
uint slice[6];
uint chan[6];
long pwm_frequency;
float dead_zone;
} RP2040DriverParams;
#endif
|
#include "./samd_mcu.h"
#ifdef _SAMD21_
#pragma message("")
#pragma message("SimpleFOC: compiling for SAMD21")
#pragma message("")
#ifndef TCC3_CH0
#define TCC3_CH0 NOT_ON_TIMER
#endif
#ifndef TCC3_CH1
#define TCC3_CH1 NOT_ON_TIMER
#endif
#ifndef TCC3_CH2
#define TCC3_CH2 NOT_ON_TIMER
#endif
#ifndef TCC3_CH3
#... |
#include "./samd_mcu.h"
#if defined(_SAMD51_)||defined(_SAME51_)
#pragma message("")
#pragma message("SimpleFOC: compiling for SAMD51/SAME51")
#pragma message("")
// expected frequency on DPLL, since we don't configure it ourselves. Typically this is the CPU frequency.
// for custom boards or overclockers you ... |
#include "./samd_mcu.h"
#if defined(_SAMD21_)||defined(_SAMD51_)||defined(_SAME51_)
/**
* Global state
*/
tccConfiguration tccPinConfigurations[SIMPLEFOC_SAMD_MAX_TCC_PINCONFIGURATIONS];
uint8_t numTccPinConfigurations = 0;
bool SAMDClockConfigured = false;
bool tccConfigured[TCC_INST_NUM+TC_INST_NUM];
/*... |
#ifndef SAMD_MCU_H
#define SAMD_MCU_H
// uncomment to enable debug output from SAMD driver
// can set this as build-flag in Arduino IDE or PlatformIO
// #define SIMPLEFOC_SAMD_DEBUG
#include "../../hardware_api.h"
#if defined(__SAME51J19A__) || defined(__ATSAME51J19A__)
#ifndef _SAME51_
#define _SAME51_
#endif
#e... |
#include "../../hardware_api.h"
#include "./stm32_mcu.h"
#include "./stm32_timerutils.h"
#include "./stm32_searchtimers.h"
#if defined(_STM32_DEF_) || defined(TARGET_STM32H7) // if stm32duino or portenta
#pragma message("")
#pragma message("SimpleFOC: compiling for STM32")
#pragma message("")
/*
* Timer managemen... |
#pragma once
#include "../../hardware_api.h"
#if defined(_STM32_DEF_) || defined(TARGET_STM32H7)
// TARGET_M4 / TARGET_M7
#ifndef SIMPLEFOC_STM32_MAX_TIMERSUSED
#define SIMPLEFOC_STM32_MAX_TIMERSUSED 6
#endif
#ifndef SIMPLEFOC_STM32_MAX_TIMERSRESERVED
#define SIMPLEFOC_STM32_MAX_TIMERSRESERVED 4
#endif
#ifndef SIMPL... |
#include "./stm32_searchtimers.h"
#include "./stm32_timerutils.h"
#if defined(_STM32_DEF_) || defined(TARGET_STM32H7)
/*
timer combination scoring function
assigns a score, and also checks the combination is valid
returns <0 if combination is invalid, >=0 if combination is valid. lower (but positive) score i... |
#pragma once
#include "./stm32_mcu.h"
#if defined(_STM32_DEF_) || defined(TARGET_STM32H7)
int stm32_findBestTimerCombination(int numPins, int pins[], PinMap* pinTimers[]);
#endif
|
#include "./stm32_timerutils.h"
#include <Arduino.h>
#if defined(_STM32_DEF_) || defined(TARGET_STM32H7) // if stm32duino or portenta
void stm32_pauseTimer(TIM_HandleTypeDef* handle){
/* Disable timer unconditionally. Required to guarantee timer is stopped,
* even if some channels are still running */
LL_TIM... |
#pragma once
#include "./stm32_mcu.h"
#if defined(_STM32_DEF_) || defined(TARGET_STM32H7)
void stm32_pauseTimer(TIM_HandleTypeDef* handle);
void stm32_resumeTimer(TIM_HandleTypeDef* handle);
void stm32_refreshTimer(TIM_HandleTypeDef* handle);
void stm32_pauseChannel(TIM_HandleTypeDef* handle, uint32_t llchannels);
... |
#include "teensy_mcu.h"
// if defined
// - Teensy 3.0 MK20DX128
// - Teensy 3.1/3.2 MK20DX256
// - Teensy LC MKL26Z64
// - Teensy 3.5 MK64FX512
// - Teensy 3.6 MK66FX1M0
#if defined(__arm__) && defined(CORE_TEENSY) && (defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MKL26Z64__) || defined(__MK64FX512__... |
#include "teensy4_mcu.h"
#include "../../../communication/SimpleFOCDebug.h"
// if defined
// - Teensy 4.0
// - Teensy 4.1
#if defined(__arm__) && defined(CORE_TEENSY) && ( defined(__IMXRT1062__) || defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41) || defined(ARDUINO_TEENSY_MICROMOD) )
#pragma message("")
#pra... |
#ifndef TEENSY4_MCU_DRIVER_H
#define TEENSY4_MCU_DRIVER_H
#include "teensy_mcu.h"
// if defined
// - Teensy 4.0
// - Teensy 4.1
#if defined(__arm__) && defined(CORE_TEENSY) && ( defined(__IMXRT1062__) || defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41) || defined(ARDUINO_TEENSY_MICROMOD) )
// teensy 4 drive... |
#include "teensy_mcu.h"
#if defined(__arm__) && defined(CORE_TEENSY)
#include "../../../communication/SimpleFOCDebug.h"
// configure High PWM frequency
void _setHighFrequency(const long freq, const int pin){
analogWrite(pin, 0);
analogWriteFrequency(pin, freq);
}
// function setting the high pwm frequency to ... |
#ifndef TEENSY_MCU_DRIVER_H
#define TEENSY_MCU_DRIVER_H
#include "../../hardware_api.h"
#if defined(__arm__) && defined(CORE_TEENSY)
#define _PWM_FREQUENCY 25000 // 25khz
#define _PWM_FREQUENCY_MAX 50000 // 50khz
// debugging output
#define SIMPLEFOC_TEENSY_DEBUG
typedef struct TeensyDriverParams {
int pins[6]... |
#include "Encoder.h"
/*
Encoder(int encA, int encB , int cpr, int index)
- encA, encB - encoder A and B pins
- cpr - counts per rotation number (cpm=ppm*4)
- index pin - (optional input)
*/
Encoder::Encoder(int _encA, int _encB , float _ppr, int _index){
// Encoder measurement structure i... |
#ifndef ENCODER_LIB_H
#define ENCODER_LIB_H
#include "Arduino.h"
#include "../common/foc_utils.h"
#include "../common/time_utils.h"
#include "../common/base_classes/Sensor.h"
/**
* Quadrature mode configuration structure
*/
enum Quadrature : uint8_t {
ON = 0x00, //!< Enable quadrature mode CPR = 4xPPR
OFF... |
#include "GenericSensor.h"
/*
GenericSensor( float (*readCallback)() )
- readCallback - pointer to the function which reads the sensor angle.
*/
GenericSensor::GenericSensor(float (*readCallback)(), void (*initCallback)()){
// if function provided add it to the
if(readCallback != nullptr) this->readCallback... |
#ifndef GENERIC_SENSOR_LIB_H
#define GENERIC_SENSOR_LIB_H
#include "Arduino.h"
#include "../common/foc_utils.h"
#include "../common/time_utils.h"
#include "../common/base_classes/Sensor.h"
class GenericSensor: public Sensor{
public:
/**
GenericSensor class constructor
* @param readCallback pointer to t... |
#include "HallSensor.h"
/*
HallSensor(int hallA, int hallB , int cpr, int index)
- hallA, hallB, hallC - HallSensor A, B and C pins
- pp - pole pairs
*/
HallSensor::HallSensor(int _hallA, int _hallB, int _hallC, int _pp){
// hardware pins
pinA = _hallA;
pinB = _hallB;
pinC = _hallC;
// ... |
#ifndef HALL_SENSOR_LIB_H
#define HALL_SENSOR_LIB_H
#include "Arduino.h"
#include "../common/base_classes/Sensor.h"
#include "../common/foc_utils.h"
#include "../common/time_utils.h"
// seq 1 > 5 > 4 > 6 > 2 > 3 > 1 000 001 010 011 100 101 110 111
const int8_t ELECTRIC_SECTORS[8] = { -1, 0, 4, 5, 2, 1, 3 , ... |
#include "MagneticSensorAnalog.h"
/** MagneticSensorAnalog(uint8_t _pinAnalog, int _min, int _max)
* @param _pinAnalog the pin that is reading the pwm from magnetic sensor
* @param _min_raw_count the smallest expected reading. Whilst you might expect it to be 0 it is often ~15. Getting this wrong results in a sm... |
#ifndef MAGNETICSENSORANALOG_LIB_H
#define MAGNETICSENSORANALOG_LIB_H
#include "Arduino.h"
#include "../common/base_classes/Sensor.h"
#include "../common/foc_utils.h"
#include "../common/time_utils.h"
/**
* This sensor has been tested with AS5600 running in 'analog mode'. This is where output pin of AS6000 is conne... |
#include "MagneticSensorI2C.h"
/** Typical configuration for the 12bit AMS AS5600 magnetic sensor over I2C interface */
MagneticSensorI2CConfig_s AS5600_I2C = {
.chip_address = 0x36,
.bit_resolution = 12,
.angle_register = 0x0C,
.msb_mask = 0x0F,
.msb_shift = 8,
.lsb_mask = 0xFF,
.lsb_shift = 0
};
/** T... |
#ifndef MAGNETICSENSORI2C_LIB_H
#define MAGNETICSENSORI2C_LIB_H
#include "Arduino.h"
#include <Wire.h>
#include "../common/base_classes/Sensor.h"
#include "../common/foc_utils.h"
#include "../common/time_utils.h"
struct MagneticSensorI2CConfig_s {
uint8_t chip_address;
uint8_t bit_resolution;
uint8_t angle_reg... |
#include "MagneticSensorPWM.h"
#include "Arduino.h"
/** MagneticSensorPWM(uint8_t _pinPWM, int _min, int _max)
* @param _pinPWM the pin that is reading the pwm from magnetic sensor
* @param _min_raw_count the smallest expected reading
* @param _max_raw_count the largest expected reading
*/
MagneticSensorPWM::Ma... |
#ifndef MAGNETICSENSORPWM_LIB_H
#define MAGNETICSENSORPWM_LIB_H
#include "Arduino.h"
#include "../common/base_classes/Sensor.h"
#include "../common/foc_utils.h"
#include "../common/time_utils.h"
// This sensor has been tested with AS5048a running in PWM mode.
class MagneticSensorPWM: public Sensor{
public:
/** M... |
#include "MagneticSensorSPI.h"
/** Typical configuration for the 14bit AMS AS5147 magnetic sensor over SPI interface */
MagneticSensorSPIConfig_s AS5147_SPI = {
.spi_mode = SPI_MODE1,
.clock_speed = 1000000,
.bit_resolution = 14,
.angle_register = 0x3FFF,
.data_start_bit = 13,
.command_rw_bit = 14,
.com... |
#ifndef MAGNETICSENSORSPI_LIB_H
#define MAGNETICSENSORSPI_LIB_H
#include "Arduino.h"
#include <SPI.h>
#include "../common/base_classes/Sensor.h"
#include "../common/foc_utils.h"
#include "../common/time_utils.h"
#define DEF_ANGLE_REGISTER 0x3FFF
struct MagneticSensorSPIConfig_s {
int spi_mode;
long clock_speed... |
// Copyright (c) Sandeep Mistry. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#include <LoRa.h>
// registers
#define REG_FIFO 0x00
#define REG_OP_MODE 0x01
#define REG_FRF_MSB 0x06
#define REG_FRF_M... |
// Copyright (c) Sandeep Mistry. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#ifndef LORA_H
#define LORA_H
#include <Arduino.h>
#include <SPI.h>
#if defined(ARDUINO_SAMD_MKRWAN1300)
#define LORA_DEFAULT_SPI SPI1
#define LORA_DEF... |
#ifndef CAN_H_
#define CAN_H_
#include <stdint.h>
typedef unsigned char __u8;
typedef unsigned short __u16;
typedef unsigned long __u32;
/* special address description flags for the CAN_ID */
#define CAN_EFF_FLAG 0x80000000UL /* EFF/SFF is set in the MSB */
#define CAN_RTR_FLAG 0x40000000UL /* remote transmission ... |
#include "Arduino.h"
#include "mcp2515.h"
const struct MCP2515::TXBn_REGS MCP2515::TXB[MCP2515::N_TXBUFFERS] = {
{MCP_TXB0CTRL, MCP_TXB0SIDH, MCP_TXB0DATA},
{MCP_TXB1CTRL, MCP_TXB1SIDH, MCP_TXB1DATA},
{MCP_TXB2CTRL, MCP_TXB2SIDH, MCP_TXB2DATA}
};
const struct MCP2515::RXBn_REGS MCP2515::RXB[N_RXBUFFERS] =... |
#ifndef _MCP2515_H_
#define _MCP2515_H_
#include <SPI.h>
#include "can.h"
/*
* Speed 8M
*/
#define MCP_8MHz_1000kBPS_CFG1 (0x00)
#define MCP_8MHz_1000kBPS_CFG2 (0x80)
#define MCP_8MHz_1000kBPS_CFG3 (0x80)
#define MCP_8MHz_500kBPS_CFG1 (0x00)
#define MCP_8MHz_500kBPS_CFG2 (0x90)
#define MCP_8MHz_500kBPS_CFG3 (0x82... |
#include "DallasTemperature.h"
#if ARDUINO >= 100
#include "Arduino.h"
#else
extern "C" {
#include "WConstants.h"
}
#endif
// OneWire commands
#define STARTCONVO 0x44 // Tells device to take a temperature reading
#define COPYSCRATCH 0x48 // Copy scratchpad to EEPROM
#define READSCRATCH 0xBE // Read fr... |
#ifndef DallasTemperature_h
#define DallasTemperature_h
#define DALLASTEMPLIBVERSION "4.0.5"
// Configuration
#ifndef REQUIRESNEW
#define REQUIRESNEW false
#endif
#ifndef REQUIRESALARMS
#define REQUIRESALARMS true
#endif
// Includes
#include <inttypes.h>
#include <Arduino.h>
#ifdef __STM32F1__
#include <OneWireSTM... |
#define ARDUINO_CI 1
// Mock OneWire GPIO functions
uint8_t digitalPinToBitMask(uint8_t pin) { return 1 << (pin % 8); }
void* digitalPinToPort(uint8_t pin) { static uint8_t dummy; return &dummy; }
void* portModeRegister(void* port) { return port; } |
#ifndef CRC16_H
#define CRC16_H
#ifdef __cplusplus
extern "C" {
#endif
// Pure C implementation to replace the ASM version
static inline uint16_t _crc16_update(uint16_t crc, uint8_t data) {
unsigned int i;
crc ^= data;
for (i = 0; i < 8; ++i) {
if (crc & 1)
crc = (crc >> 1) ^ 0xA001;
... |
#include <DallasTemperature.h>
#include <ArduinoUnitTests.h>
unittest(test_initialization) {
OneWire oneWire(2); // Simulate OneWire on pin 2
DallasTemperature sensors(&oneWire);
sensors.begin();
assertEqual(0, sensors.getDeviceCount());
}
unittest(test_parasite_power_mode) {
OneWire oneWire(2);
... |
// FILE: unit_test_001.cpp
// AUTHOR: Miles Burton / Rob Tillaart
// DATE: 2021-01-10
// PURPOSE: unit tests for the Arduino-Temperature-Control-Library
// https://github.com/MilesBurton/Arduino-Temperature-Control-Library
#include <ArduinoUnitTests.h>
#include <Arduino.h>
#include <OneWire.h>
#includ... |
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2025, Benoit BLANCHON
// MIT License
#include "src/ArduinoJson.h"
|
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2025, Benoit BLANCHON
// MIT License
#include <ArduinoJson.h>
extern "C" void app_main() {
char buffer[256];
JsonDocument doc;
doc["hello"] = "world";
serializeJson(doc, buffer);
deserializeJson(doc, buffer);
serializeMsgPack(doc, buffer);
d... |
#include <ArduinoJson.h>
static_assert(ARDUINOJSON_ENABLE_PROGMEM == 1, "ARDUINOJSON_ENABLE_PROGMEM");
static_assert(ARDUINOJSON_USE_LONG_LONG == 0, "ARDUINOJSON_USE_LONG_LONG");
static_assert(ARDUINOJSON_SLOT_ID_SIZE == 1, "ARDUINOJSON_SLOT_ID_SIZE");
static_assert(ARDUINOJSON_POOL_CAPACITY == 16, "ARDUINOJSON_POO... |
#include <ArduinoJson.h>
static_assert(ARDUINOJSON_USE_LONG_LONG == 1, "ARDUINOJSON_USE_LONG_LONG");
static_assert(ARDUINOJSON_SLOT_ID_SIZE == 2, "ARDUINOJSON_SLOT_ID_SIZE");
static_assert(ARDUINOJSON_POOL_CAPACITY == 128, "ARDUINOJSON_POOL_CAPACITY");
static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITT... |
#include <ArduinoJson.h>
static_assert(ARDUINOJSON_USE_LONG_LONG == 1, "ARDUINOJSON_USE_LONG_LONG");
static_assert(ARDUINOJSON_SLOT_ID_SIZE == 4, "ARDUINOJSON_SLOT_ID_SIZE");
static_assert(ARDUINOJSON_POOL_CAPACITY == 256, "ARDUINOJSON_POOL_CAPACITY");
static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITT... |
#include <ArduinoJson.h>
static_assert(ARDUINOJSON_USE_LONG_LONG == 1, "ARDUINOJSON_USE_LONG_LONG");
static_assert(ARDUINOJSON_SLOT_ID_SIZE == 2, "ARDUINOJSON_SLOT_ID_SIZE");
static_assert(ARDUINOJSON_POOL_CAPACITY == 128, "ARDUINOJSON_POOL_CAPACITY");
static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITT... |
#include <ArduinoJson.h>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
JsonDocument doc;
DeserializationError error = deserializeJson(doc, data, size);
if (!error) {
std::string json;
serializeJson(doc, json);
}
return 0;
}
|
#include <ArduinoJson.h>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
JsonDocument doc;
DeserializationError error = deserializeMsgPack(doc, data, size);
if (!error) {
std::string json;
serializeMsgPack(doc, json);
}
return 0;
}
|
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2025, Benoit BLANCHON
// MIT License
// This file is NOT use by Google's OSS fuzz
// I only use it to reproduce the bugs found
#include <stdint.h> // size_t
#include <stdio.h> // fopen et al.
#include <stdlib.h> // exit
#include <iostream>
#include <ve... |
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2025, Benoit BLANCHON
// MIT License
//
// This example shows how to generate a JSON document with ArduinoJson.
#include <iostream>
#include "ArduinoJson.h"
int main() {
// Allocate the JSON document
JsonDocument doc;
// Add values in the document.
... |
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2025, Benoit BLANCHON
// MIT License
//
// This example shows how to deserialize a JSON document with ArduinoJson.
#include <iostream>
#include "ArduinoJson.h"
int main() {
// Allocate the JSON document
JsonDocument doc;
// JSON input string
const... |
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2025, Benoit BLANCHON
// MIT License
//
// This example shows how to generate a JSON document with ArduinoJson.
#include <iostream>
#include "ArduinoJson.h"
int main() {
// Allocate the JSON document
JsonDocument doc;
// The MessagePack input string... |
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
|
/*
* Catch v2.13.10
* Generated: 2022-10-16 11:01:23.452308
* ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2022 Two Blue Cubes Ltd. All rights reserved.
*
* Distributed under the Boost Software Li... |
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2025, Benoit BLANCHON
// MIT License
// we expect ArduinoJson.h to include <string_view>
// but we don't want it to included accidentally
#undef ARDUINO
#define ARDUINOJSON_ENABLE_STD_STREAM 0
#define ARDUINOJSON_ENABLE_STD_STRING 0
#include <ArduinoJson.h... |
#include <ArduinoJson.h>
#include <catch.hpp>
#include <string>
TEST_CASE("C++20 smoke test") {
JsonDocument doc;
deserializeJson(doc, "{\"hello\":\"world\"}");
REQUIRE(doc["hello"] == "world");
std::string json;
serializeJson(doc, json);
REQUIRE(json == "{\"hello\":\"world\"}");
}
|
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2025, Benoit BLANCHON
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("JsonArray::add()") {
JsonDocument doc;
JsonArray array = doc.to<JsonArray>();
array.add().set(42);
REQUIRE(doc.as<std::string>() == "[42]");
}
TEST_CASE(... |
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2025, Benoit BLANCHON
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
#include <string>
using ArduinoJson::detail::is_base_of;
static std::string allocatorLog;
struct CustomAllocator {
CustomAllocator() {
allocatorLog = "";
}
voi... |
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2025, Benoit BLANCHON
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
#include "Literals.hpp"
TEST_CASE("JsonDocument::containsKey()") {
JsonDocument doc;
SECTION("returns true on object") {
doc["hello"] = "world";
REQUIRE(doc.c... |
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2025, Benoit BLANCHON
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
#include <string>
#include "Literals.hpp"
TEST_CASE("JsonDocument::createNestedArray()") {
JsonDocument doc;
SECTION("createNestedArray()") {
JsonArray array = do... |
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2025, Benoit BLANCHON
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
#include <string>
#include "Literals.hpp"
TEST_CASE("JsonDocument::createNestedObject()") {
JsonDocument doc;
SECTION("createNestedObject()") {
JsonObject object ... |
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2025, Benoit BLANCHON
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
using ArduinoJson::detail::is_base_of;
TEST_CASE("DynamicJsonDocument") {
SECTION("is a JsonDocument") {
REQUIRE(is_base_of<JsonDocument, DynamicJsonDocument>::value ... |
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2025, Benoit BLANCHON
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("JSON_ARRAY_SIZE") {
REQUIRE(JSON_ARRAY_SIZE(10) == ArduinoJson::detail::sizeofArray(10));
}
TEST_CASE("JSON_OBJECT_SIZE") {
REQUIRE(JSON_OBJECT_SIZE(10) == A... |
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2025, Benoit BLANCHON
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("JsonArray::memoryUsage()") {
JsonArray array;
REQUIRE(array.memoryUsage() == 0);
}
TEST_CASE("JsonArrayConst::memoryUsage()") {
JsonArrayConst array;
REQ... |
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2025, Benoit BLANCHON
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("shallowCopy()") {
JsonDocument doc1, doc2;
doc1["b"] = "c";
doc2["a"].shallowCopy(doc1);
REQUIRE(doc2.as<std::string>() == "{\"a\":{\"b\":\"c\"}}");
}
|
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2025, Benoit BLANCHON
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
using ArduinoJson::detail::is_base_of;
TEST_CASE("StaticJsonDocument") {
SECTION("is a JsonDocument") {
REQUIRE(is_base_of<JsonDocument, StaticJsonDocument<256>>::val... |
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2025, Benoit BLANCHON
// MIT License
#include <ArduinoJson.h>
// See issue #1498
int main() {
JsonDocument doc;
doc["dummy"] = 'A';
}
|
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2025, Benoit BLANCHON
// MIT License
#include <ArduinoJson.h>
// See issue #2135
int main() {
JsonObject obj;
deserializeJson(obj, "");
}
|
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2025, Benoit BLANCHON
// MIT License
#include <ArduinoJson.h>
struct Stream {};
int main() {
Stream* stream = 0;
JsonDocument doc;
deserializeJson(doc, stream);
}
|
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2025, Benoit BLANCHON
// MIT License
#define ARDUINOJSON_USE_LONG_LONG 0
#include <ArduinoJson.h>
#if defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ >= 8
# error This test requires sizeof(long) < 8
#endif
ARDUINOJSON_ASSERT_INTEGER_TYPE_IS_SUPPORTED(long lo... |
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2025, Benoit BLANCHON
// MIT License
#include <ArduinoJson.h>
// See issue #1498
int main() {
JsonDocument doc;
doc["dummy"].as<char>();
}
|
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2025, Benoit BLANCHON
// MIT License
#define ARDUINOJSON_USE_LONG_LONG 0
#include <ArduinoJson.h>
#if defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ >= 8
# error This test requires sizeof(long) < 8
#endif
int main() {
JsonDocument doc;
doc["dummy"] = st... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.