Browse Source

analogWriteResolution() returns prior setting

teensy4-core
PaulStoffregen 7 years ago
parent
commit
77e813b2a6
2 changed files with 6 additions and 3 deletions
  1. +2
    -2
      teensy3/core_pins.h
  2. +4
    -1
      teensy3/pins_teensy.c

+ 2
- 2
teensy3/core_pins.h View File

void pinMode(uint8_t pin, uint8_t mode); void pinMode(uint8_t pin, uint8_t mode);
void init_pins(void); void init_pins(void);
void analogWrite(uint8_t pin, int val); void analogWrite(uint8_t pin, int val);
void analogWriteRes(uint32_t bits);
static inline void analogWriteResolution(uint32_t bits) { analogWriteRes(bits); }
uint32_t analogWriteRes(uint32_t bits);
static inline uint32_t analogWriteResolution(uint32_t bits) { return analogWriteRes(bits); }
void analogWriteFrequency(uint8_t pin, float frequency); void analogWriteFrequency(uint8_t pin, float frequency);
void analogWriteDAC0(int val); void analogWriteDAC0(int val);
void analogWriteDAC1(int val); void analogWriteDAC1(int val);

+ 4
- 1
teensy3/pins_teensy.c View File

} }




void analogWriteRes(uint32_t bits)
uint32_t analogWriteRes(uint32_t bits)
{ {
uint32_t prior_res;
if (bits < 1) { if (bits < 1) {
bits = 1; bits = 1;
} else if (bits > 16) { } else if (bits > 16) {
bits = 16; bits = 16;
} }
prior_res = analog_write_res;
analog_write_res = bits; analog_write_res = bits;
return prior_res;
} }





Loading…
Cancel
Save