add forced inlines
This commit is contained in:
parent
a4c93fead7
commit
1077930330
|
@ -1,3 +1,4 @@
|
||||||
sketch.yaml
|
sketch.yaml
|
||||||
midi_data.hpp
|
midi_data.hpp
|
||||||
|
build
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
|
|
||||||
void SoftTWI::set_pin(uint8_t pin, bool state) {
|
void SoftTWI::set_pin(uint8_t pin, bool state) {
|
||||||
uint8_t bitmask = digitalPinToBitMask(pin);
|
uint8_t bitmask = digitalPinToBitMask(pin);
|
||||||
volatile uint8_t& reg = *portModeRegister(digitalPinToPort(pin));
|
volatile uint8_t* reg = portModeRegister(digitalPinToPort(pin));
|
||||||
if(state) {
|
if(state) {
|
||||||
reg &= ~bitmask;
|
*reg &= ~bitmask;
|
||||||
} else {
|
} else {
|
||||||
reg |= bitmask;
|
*reg |= bitmask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
25
soft_twi.hpp
25
soft_twi.hpp
|
@ -2,36 +2,37 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include "util.hpp"
|
||||||
|
|
||||||
struct SoftTWI {
|
struct SoftTWI {
|
||||||
|
|
||||||
constexpr SoftTWI(unsigned sda, unsigned scl, unsigned delay = 0);
|
constexpr SoftTWI(unsigned sda, unsigned scl, unsigned delay = 0);
|
||||||
|
|
||||||
void begin();
|
void begin();
|
||||||
inline void sleep(uint8_t=1) {}
|
inline void sleep(uint8_t=1) AW_IN {}
|
||||||
inline void wait_scl();
|
inline void wait_scl() AW_IN;
|
||||||
|
|
||||||
void set_pin(uint8_t, bool);
|
void set_pin(uint8_t, bool);
|
||||||
inline void set_sda(bool);
|
inline void set_sda(bool) AW_IN;
|
||||||
inline void set_scl(bool);
|
inline void set_scl(bool) AW_IN;
|
||||||
|
|
||||||
bool read_pin(uint8_t);
|
bool read_pin(uint8_t);
|
||||||
inline bool read_sda();
|
inline bool read_sda() AW_IN;
|
||||||
inline bool read_scl();
|
inline bool read_scl() AW_IN;
|
||||||
|
|
||||||
inline void write_bit(bool);
|
inline void write_bit(bool) AW_IN;
|
||||||
bool write(uint8_t);
|
bool write(uint8_t);
|
||||||
unsigned write(const uint8_t*, unsigned);
|
unsigned write(const uint8_t*, unsigned);
|
||||||
|
|
||||||
inline bool read_bit();
|
inline bool read_bit() AW_IN;
|
||||||
uint8_t read(bool=true);
|
uint8_t read(bool=true);
|
||||||
void read(uint8_t*, unsigned, bool=false);
|
void read(uint8_t*, unsigned, bool=false);
|
||||||
|
|
||||||
inline bool start_read(uint8_t);
|
inline bool start_read(uint8_t) AW_IN;
|
||||||
inline bool start_write(uint8_t);
|
inline bool start_write(uint8_t) AW_IN;
|
||||||
|
|
||||||
inline void start();
|
inline void start() AW_IN;
|
||||||
inline void end();
|
inline void end() AW_IN;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned _sda;
|
unsigned _sda;
|
||||||
|
|
7
tone.hpp
7
tone.hpp
|
@ -2,6 +2,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include "util.hpp"
|
||||||
|
|
||||||
struct Tone {
|
struct Tone {
|
||||||
uint32_t phase;
|
uint32_t phase;
|
||||||
|
@ -12,15 +13,15 @@ struct Tone {
|
||||||
|
|
||||||
static void init();
|
static void init();
|
||||||
|
|
||||||
inline bool active() const {
|
inline bool active() const AW_IN {
|
||||||
return amplitude > 0;
|
return amplitude > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void update(uint32_t t) {
|
inline void update(uint32_t t) AW_IN {
|
||||||
phase += t * frequency;
|
phase += t * frequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int get() const {
|
inline int get() const AW_IN {
|
||||||
uint8_t id = phase >> 12;
|
uint8_t id = phase >> 12;
|
||||||
return (int)sin_lookup[id] * amplitude;
|
return (int)sin_lookup[id] * amplitude;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue