|
REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
|
#include <AD9834.h>


Public Member Functions | |
| AD9834 (bus::addr_t address, uint8_t alt_function_idx) | |
| bool | init () |
| Initialises the chip and puts it into sleep mode. | |
| void | write_frequency (float freq) |
| Sets the frequency of the sine / triangle output in Hz. | |
| void | write_phase (float phase) |
| Sets the phase of the outputs synchronised to the reset pin. Possible values are mapped to [0, 2PI]. | |
| void | write_wave_form (WaveForm wave_form) |
| Sets the wave form of the function generator output. | |
| float | get_real_frequency () const |
| Returns the actually set frequency, containing rounding errors. | |
| float | get_real_phase () const |
| Returns the actually set phase, containing rounding errors. Possible values are [0, 2PI]. | |
| void | sleep () |
| Sets the sine / triangle output to zero. The square output will stay at high or low level. | |
| void | awake () |
| Resumes outputs to regular operation, according to the previously specified frequencies. | |
| DataFunction (bus::addr_t address, uint8_t alt_function_idx, const SPISettings &spiSettings) | |
Public Member Functions inherited from functions::DataFunction | |
| DataFunction (bus::addr_t address, uint8_t alt_function_idx, const SPISettings &spiSettings) | |
| void | begin_communication () const |
| void | end_communication () const |
| void | transfer (const void *mosi_buf, void *miso_buf, size_t count) const |
| uint8_t | transfer8 (uint8_t data_in) const |
| uint16_t | transfer16 (uint16_t data_in) const |
| uint32_t | transfer32 (uint32_t data_in) const |
Public Member Functions inherited from functions::Function | |
| Function (bus::addr_t address) | |
Static Public Attributes | |
| static const SPISettings | DEFAULT_SPI_SETTINGS {4'000'000, MSBFIRST, SPI_MODE2} |
| static constexpr uint16_t | REG_FREQ_0 = 0x4000 |
| static constexpr uint16_t | REG_FREQ_1 = 0x8000 |
| static constexpr uint16_t | REG_PHASE_0 = 0xC000 |
| static constexpr uint16_t | REG_PHASE_1 = 0xE000 |
| static constexpr uint16_t | REG_FREQ_MASK = 0x3FFF |
| static constexpr uint16_t | REG_PHASE_MASK = 0x0FFF |
| static constexpr uint16_t | CONTROL_B28 = 0x2000 |
| static constexpr uint16_t | CONTROL_HLB = 0x1000 |
| static constexpr uint16_t | CONTROL_FSEL = 0x0800 |
| static constexpr uint16_t | CONTROL_PSEL = 0x0400 |
| static constexpr uint16_t | CONTROL_PINSW = 0x0200 |
| static constexpr uint16_t | CONTROL_RESET = 0x0100 |
| static constexpr uint16_t | CONTROL_SLEEP1 = 0x0080 |
| static constexpr uint16_t | CONTROL_SLEEP12 = 0x0040 |
| static constexpr uint16_t | CONTROL_OPBITEN = 0x0020 |
| static constexpr uint16_t | CONTROL_SIGNPIB = 0x0010 |
| static constexpr uint16_t | CONTROL_DIV2 = 0x0008 |
| static constexpr uint16_t | CONTROL_MODE = 0x0002 |
| static constexpr uint16_t | ENABLE_SQUARE_WAVE = CONTROL_OPBITEN |
| static constexpr uint16_t | ENABLE_TRIANGLE_WAVE = CONTROL_MODE |
| static constexpr float | MASTER_CLK = 75000000.0f |
Additional Inherited Members | |
Public Attributes inherited from functions::DataFunction | |
| const SPISettings & | spi_settings |
Public Attributes inherited from functions::Function | |
| const bus::addr_t | address |
Static Protected Member Functions inherited from functions::DataFunction | |
| static SPIClass & | get_raw_spi () |
Protected Attributes inherited from functions::DataFunction | |
| bus::addr_t | alt_function_address |
| bool | use_csel = false |
Detailed Description
Constructor & Destructor Documentation
◆ AD9834()
|
explicit |
Definition at line 10 of file AD9834.cpp.
References functions::Function::address, DataFunction(), and DEFAULT_SPI_SETTINGS.
Member Function Documentation
◆ awake()
| void functions::AD9834::awake | ( | ) |
Resumes outputs to regular operation, according to the previously specified frequencies.
Definition at line 36 of file AD9834.cpp.
References CONTROL_SLEEP1, and CONTROL_SLEEP12.
◆ DataFunction()
| functions::DataFunction::DataFunction | ( | bus::addr_t | address, |
| uint8_t | alt_function_idx, | ||
| const SPISettings & | spiSettings ) |
Definition at line 68 of file functions.cpp.
Referenced by AD9834().
◆ get_real_frequency()
| float functions::AD9834::get_real_frequency | ( | ) | const |
Returns the actually set frequency, containing rounding errors.
Definition at line 78 of file AD9834.cpp.
References MASTER_CLK.
◆ get_real_phase()
| float functions::AD9834::get_real_phase | ( | ) | const |
Returns the actually set phase, containing rounding errors. Possible values are [0, 2PI].
Definition at line 82 of file AD9834.cpp.
◆ init()
| bool functions::AD9834::init | ( | ) |
Initialises the chip and puts it into sleep mode.
Definition at line 13 of file AD9834.cpp.
References functions::DataFunction::begin_communication(), CONTROL_B28, CONTROL_DIV2, CONTROL_PINSW, CONTROL_RESET, CONTROL_SLEEP1, CONTROL_SLEEP12, functions::DataFunction::end_communication(), and functions::DataFunction::get_raw_spi().
◆ sleep()
| void functions::AD9834::sleep | ( | ) |
Sets the sine / triangle output to zero. The square output will stay at high or low level.
Definition at line 29 of file AD9834.cpp.
References CONTROL_SLEEP1, and CONTROL_SLEEP12.
◆ write_frequency()
| void functions::AD9834::write_frequency | ( | float | freq | ) |
Sets the frequency of the sine / triangle output in Hz.
Note that the square output will always operate on half of the specified frequency.
Definition at line 61 of file AD9834.cpp.
References functions::DataFunction::begin_communication(), functions::DataFunction::end_communication(), functions::DataFunction::get_raw_spi(), MASTER_CLK, REG_FREQ_0, REG_FREQ_MASK, and uint32_t.
◆ write_phase()
| void functions::AD9834::write_phase | ( | float | phase | ) |
Sets the phase of the outputs synchronised to the reset pin. Possible values are mapped to [0, 2PI].
Definition at line 70 of file AD9834.cpp.
References functions::DataFunction::begin_communication(), functions::DataFunction::end_communication(), functions::DataFunction::get_raw_spi(), REG_PHASE_0, and REG_PHASE_MASK.
◆ write_wave_form()
| void functions::AD9834::write_wave_form | ( | WaveForm | wave_form | ) |
Sets the wave form of the function generator output.
Definition at line 43 of file AD9834.cpp.
References ENABLE_SQUARE_WAVE, and ENABLE_TRIANGLE_WAVE.
Member Data Documentation
◆ CONTROL_B28
|
staticconstexpr |
◆ CONTROL_DIV2
|
staticconstexpr |
◆ CONTROL_FSEL
|
staticconstexpr |
◆ CONTROL_HLB
|
staticconstexpr |
◆ CONTROL_MODE
|
staticconstexpr |
◆ CONTROL_OPBITEN
|
staticconstexpr |
◆ CONTROL_PINSW
|
staticconstexpr |
◆ CONTROL_PSEL
|
staticconstexpr |
◆ CONTROL_RESET
|
staticconstexpr |
◆ CONTROL_SIGNPIB
|
staticconstexpr |
◆ CONTROL_SLEEP1
|
staticconstexpr |
◆ CONTROL_SLEEP12
|
staticconstexpr |
◆ DEFAULT_SPI_SETTINGS
|
static |
◆ ENABLE_SQUARE_WAVE
|
staticconstexpr |
Definition at line 39 of file AD9834.h.
Referenced by write_wave_form().
◆ ENABLE_TRIANGLE_WAVE
|
staticconstexpr |
Definition at line 40 of file AD9834.h.
Referenced by write_wave_form().
◆ MASTER_CLK
|
staticconstexpr |
Definition at line 42 of file AD9834.h.
Referenced by get_real_frequency(), and write_frequency().
◆ REG_FREQ_0
|
staticconstexpr |
Definition at line 18 of file AD9834.h.
Referenced by write_frequency().
◆ REG_FREQ_1
|
staticconstexpr |
◆ REG_FREQ_MASK
|
staticconstexpr |
Definition at line 23 of file AD9834.h.
Referenced by write_frequency().
◆ REG_PHASE_0
|
staticconstexpr |
Definition at line 20 of file AD9834.h.
Referenced by write_phase().
◆ REG_PHASE_1
|
staticconstexpr |
◆ REG_PHASE_MASK
|
staticconstexpr |
Definition at line 24 of file AD9834.h.
Referenced by write_phase().
The documentation for this class was generated from the following files:
- lib/hardware/src/chips/AD9834.h
- lib/hardware/src/chips/AD9834.cpp
Public Member Functions inherited from