diff --git a/docs/api.md b/docs/api.md new file mode 100644 index 0000000..fa82b7e --- /dev/null +++ b/docs/api.md @@ -0,0 +1,403 @@ +# Arduino Advanced Analog Library + +## AdvancedADC + +### `AdvancedADC` + +Creates an object associated to a specific pin. + +#### Syntax + +``` +AdvancedADC adc(analogPin); +``` + +#### Parameters + +- Pin `A0` through `A11` can be associated. + +#### Returns + +Nothing. + +### `begin()` + + +Initializes the ADC with the specific parameters. The `begin()` method is firstly used to initialize the library. + +If reconfigured during program execution, use `stop()` first. + +#### Syntax + +``` +adc0.begin(resolution, sample_rate, n_samples, n_buffers) +``` + +#### Parameters + +- `enum` - resolution (choose from 8, 10, 12, 14, 16 bit) + - `AN_RESOLUTION_8` + - `AN_RESOLUTION_10` + - `AN_RESOLUTION_12` + - `AN_RESOLUTION_14` + - `AN_RESOLUTION_16` +- `int` - frequency +- `int` - n_samples +- `int` - n_buffers + +#### Returns + +1 on success, 0 on failure. + +### `available()` + +Bool to check if there's any available data on the ADC channel. + +#### Syntax + +``` +if(adc0.available()){} +``` + +#### Parameters + +None. + +#### Returns + +1 on success, 0 on failure. + +### `read()` + +Reads the first available byte in the buffer. + +### `stop()` + +Stops the ADC and buffer transfer, and releases any memory allocated for the buffer array. + +#### Syntax + +``` +adc.stop() +``` + +#### Returns + +- `1` + +## AdvancedDAC + +### `AdvancedDAC` + + +Creates a DAC object on a specific pin. + +#### Syntax + +``` +AdvancedDAC dac0(A12); +AdvancedDAC dac1(A13); +``` + +#### Parameters + +- `A12` or `A13` (DAC0 or DAC1 channels). + +#### Returns + +Nothing. + +### `begin()` + + +Initializes the DAC with the specific parameters. The `begin()` method is firstly used to initialize the library. + +If reconfigured during program execution, use `stop()` first. + +#### Syntax + +``` +dac0.begin(resolution, frequency, n_samples, n_buffers) +``` + +#### Parameters + +- `enum` - resolution (choose from 8, 10, 12 bit) + - `AN_RESOLUTION_8` + - `AN_RESOLUTION_10` + - `AN_RESOLUTION_12` +- `int` - frequency +- `int` - n_samples +- `int` - n_buffers + +#### Returns + +1 on success, 0 on failure. + +### `available()` + +Checks if the DAC channel is available to write to. + +#### Syntax + +``` +if(dac0.available()){} +``` + +#### Parameters + +None. + +#### Returns + +1 on success, 0 on failure. + + +### `dequeue()` + + +Creates a buffer object and waits until a buffer to become available. + +#### Syntax + +``` +SampleBuffer buf = dac.dequeue(); + +for (size_t i=0; i +``` +