-
-
Notifications
You must be signed in to change notification settings - Fork 37
Zephyr
We are providing a DRAFT implementation for Zephyr.
In Arduino and other microcontroller frameworks the pins are defined as integers and this library is used to define all relevant devices and the corresponding pins. In Zephyr however, the pins and related device logic is represented in the device tree.
So when using Zephyr this project is used to link the devices with the corresponding device tree definitions.
#include "AudioBoard.h"
DriverPins my_pins; AudioBoard board(AudioDriverES8388, my_pins);
void setup() { // add i2c codec my_pins.addI2C(PinFunction::CODEC, DEVICE_DT_GET(DT_ALIAS(i2c_1))); // add i2s my_pins.addI2S(PinFunction::CODEC, DEVICE_DT_GET(DT_ALIAS(i2s_1))); // add other pins: PA on gpio 21 my_pins.addPin(PinFunction::PA, GPIO_DT_SPEC_GET(DT_ALIAS(gpio_pa), gpios), PinLogic::Output);
// configure codec
CodecConfig cfg;
cfg.adc_input = ADC_INPUT_LINE1;
cfg.dac_output = DAC_OUTPUT_ALL;
cfg.i2s.bits = BIT_LENGTH_16BITS;
cfg.i2s.rate = RATE_44K;
//cfg.i2s.fmt = I2S_NORMAL;
//cfg.i2s.mode = MODE_SLAVE;
board.begin(cfg);
}