10#include "../../hardware_api.h"
13#if defined(__SAME51J19A__) || defined(__ATSAME51J19A__)
20#if defined(_SAMD21_)||defined(_SAMD51_)||defined(_SAME51_)
25#include "wiring_private.h"
28#ifndef SIMPLEFOC_SAMD_PWM_RESOLUTION
29#define SIMPLEFOC_SAMD_PWM_RESOLUTION 1000
32#define SIMPLEFOC_SAMD_DEFAULT_PWM_FREQUENCY_HZ 24000
34#define SIMPLEFOC_SAMD_MAX_PWM_RESOLUTION 30000
37#define SIMPLEFOC_SAMD_MIN_PWM_RESOLUTION 400
39#define SIMPLEFOC_SAMD_PWM_TC_RESOLUTION 250
41#ifndef SIMPLEFOC_SAMD_MAX_TCC_PINCONFIGURATIONS
42#define SIMPLEFOC_SAMD_MAX_TCC_PINCONFIGURATIONS 24
47struct tccConfiguration {
66struct wo_association {
73#if defined(_SAMD51_)||defined(_SAME51_)
81typedef struct SAMDHardwareDriverParams {
82 tccConfiguration* tccPinConfigurations[6];
83 uint32_t pwm_frequency;
85} SAMDHardwareDriverParams;
91#define NUM_PIO_TIMER_PERIPHERALS 2
92#elif defined(_SAMD51_)||defined(_SAME51_)
93#define NUM_PIO_TIMER_PERIPHERALS 3
101extern struct wo_association WO_associations[];
102extern uint8_t TCC_CHANNEL_COUNT[];
103extern tccConfiguration tccPinConfigurations[SIMPLEFOC_SAMD_MAX_TCC_PINCONFIGURATIONS];
104extern uint8_t numTccPinConfigurations;
105extern bool SAMDClockConfigured;
106extern bool tccConfigured[TCC_INST_NUM+TC_INST_NUM];
110struct wo_association& getWOAssociation(EPortType port, uint32_t pin);
111void writeSAMDDutyCycle(tccConfiguration* info,
float dc);
112void configureSAMDClock();
113void configureTCC(tccConfiguration& tccConfig,
long pwm_frequency,
bool negate=
false,
float hw6pwm=-1);
114__inline__
void syncTCC(Tcc* TCCx)
__attribute__((always_inline, unused));
115EPioType getPeripheralOfPermutation(
int permutation,
int pin_position);
117#ifdef SIMPLEFOC_SAMD_DEBUG
118void printTCCConfiguration(tccConfiguration& info);
119void printAllPinInfos();
__attribute__((weak)) float _sin(float a)