SimpleFOClibrary  2.1
drivers/hardware_specific/generic_mcu.cpp
Go to the documentation of this file.
1 #include "../hardware_api.h"
2 
3 #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega328PB__) // if mcu is not atmega328
4 
5 #elif defined(__AVR_ATmega2560__) // if mcu is not atmega2560
6 
7 #elif defined(__arm__) && defined(CORE_TEENSY) // or teensy
8 
9 #elif defined(__arm__) && defined(__SAM3X8E__) // or due
10 
11 #elif defined(ESP_H) // or esp32
12 
13 #elif defined(_STM32_DEF_) // or stm32
14 
15 #elif defined(_SAMD21_) // samd21 for the moment, samd51 in progress...
16 
17 #else
18 
19 // function setting the high pwm frequency to the supplied pins
20 // - Stepper motor - 2PWM setting
21 // - hardware speciffic
22 // in generic case dont do anything
23 void _configure2PWM(long pwm_frequency,const int pinA, const int pinB) {
24  return;
25 }
26 
27 // function setting the high pwm frequency to the supplied pins
28 // - BLDC motor - 3PWM setting
29 // - hardware speciffic
30 // in generic case dont do anything
31 void _configure3PWM(long pwm_frequency,const int pinA, const int pinB, const int pinC) {
32  return;
33 }
34 
35 
36 // function setting the high pwm frequency to the supplied pins
37 // - Stepper motor - 4PWM setting
38 // - hardware speciffic
39 // in generic case dont do anything
40 void _configure4PWM(long pwm_frequency,const int pin1A, const int pin1B, const int pin2A, const int pin2B) {
41  return;
42 }
43 
44 // Configuring PWM frequency, resolution and alignment
45 // - BLDC driver - 6PWM setting
46 // - hardware specific
47 int _configure6PWM(long pwm_frequency, float dead_zone, const int pinA_h, const int pinA_l, const int pinB_h, const int pinB_l, const int pinC_h, const int pinC_l){
48  return -1;
49 }
50 
51 
52 // function setting the pwm duty cycle to the hardware
53 // - Stepper motor - 2PWM setting
54 // - hardware speciffic
55 void _writeDutyCycle2PWM(float dc_a, float dc_b, int pinA, int pinB){
56  // transform duty cycle from [0,1] to [0,255]
57  analogWrite(pinA, 255.0*dc_a);
58  analogWrite(pinB, 255.0*dc_b);
59 }
60 
61 // function setting the pwm duty cycle to the hardware
62 // - BLDC motor - 3PWM setting
63 // - hardware speciffic
64 void _writeDutyCycle3PWM(float dc_a, float dc_b, float dc_c, int pinA, int pinB, int pinC){
65  // transform duty cycle from [0,1] to [0,255]
66  analogWrite(pinA, 255.0*dc_a);
67  analogWrite(pinB, 255.0*dc_b);
68  analogWrite(pinC, 255.0*dc_c);
69 }
70 
71 // function setting the pwm duty cycle to the hardware
72 // - Stepper motor - 4PWM setting
73 // - hardware speciffic
74 void _writeDutyCycle4PWM(float dc_1a, float dc_1b, float dc_2a, float dc_2b, int pin1A, int pin1B, int pin2A, int pin2B){
75  // transform duty cycle from [0,1] to [0,255]
76  analogWrite(pin1A, 255.0*dc_1a);
77  analogWrite(pin1B, 255.0*dc_1b);
78  analogWrite(pin2A, 255.0*dc_2a);
79  analogWrite(pin2B, 255.0*dc_2b);
80 }
81 
82 
83 // Function setting the duty cycle to the pwm pin (ex. analogWrite())
84 // - BLDC driver - 6PWM setting
85 // - hardware specific
86 void _writeDutyCycle6PWM(float dc_a, float dc_b, float dc_c, float dead_zone, int pinA_h, int pinA_l, int pinB_h, int pinB_l, int pinC_h, int pinC_l){
87  return;
88 }
89 
90 
91 #endif
_writeDutyCycle6PWM
void _writeDutyCycle6PWM(float dc_a, float dc_b, float dc_c, float dead_zone, int pinA_h, int pinA_l, int pinB_h, int pinB_l, int pinC_h, int pinC_l)
Definition: drivers/hardware_specific/generic_mcu.cpp:86
_configure6PWM
int _configure6PWM(long pwm_frequency, float dead_zone, const int pinA_h, const int pinA_l, const int pinB_h, const int pinB_l, const int pinC_h, const int pinC_l)
Definition: drivers/hardware_specific/generic_mcu.cpp:47
_writeDutyCycle4PWM
void _writeDutyCycle4PWM(float dc_1a, float dc_1b, float dc_2a, float dc_2b, int pin1A, int pin1B, int pin2A, int pin2B)
Definition: drivers/hardware_specific/generic_mcu.cpp:74
_configure3PWM
void _configure3PWM(long pwm_frequency, const int pinA, const int pinB, const int pinC)
Definition: drivers/hardware_specific/generic_mcu.cpp:31
_writeDutyCycle2PWM
void _writeDutyCycle2PWM(float dc_a, float dc_b, int pinA, int pinB)
Definition: drivers/hardware_specific/generic_mcu.cpp:55
_configure2PWM
void _configure2PWM(long pwm_frequency, const int pinA, const int pinB)
Definition: drivers/hardware_specific/generic_mcu.cpp:23
_writeDutyCycle3PWM
void _writeDutyCycle3PWM(float dc_a, float dc_b, float dc_c, int pinA, int pinB, int pinC)
Definition: drivers/hardware_specific/generic_mcu.cpp:64
_configure4PWM
void _configure4PWM(long pwm_frequency, const int pin1A, const int pin1B, const int pin2A, const int pin2B)
Definition: drivers/hardware_specific/generic_mcu.cpp:40