Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
DMAFuncGen.h
00001 #ifndef MBED_DMAFUNCGEN_H 00002 #define MBED_DMAFUNCGEN_H 00003 00004 #include "mbed.h" 00005 #include "MODDMA.h" 00006 00007 //! DMAFuncGen class generates a waveform on Analog output using Direct Memory Access alone. 00008 class DMAFuncGen { 00009 public: 00010 /// Create DMAFucGen instance 00011 /// @param dma The dma to use. 00012 /// @param channel The dma channel to use for transferring data to the D/A converter. 00013 DMAFuncGen(MODDMA& dma, MODDMA::CHANNELS channel); 00014 00015 /// Number of data points in the waveform. Must be set by client. 00016 int buffer_size; 00017 /// Buffer for the binary data that will be transferred by DMA. Must be allocated by client. 00018 uint32_t* buffer; 00019 00020 /// Set waveform value for a specified data point. 00021 /// @param idx The index of the data point in #buffer, must be in range 0..#buffer_size-1. 00022 /// @param x The value for the D/A, in the range 0..65535. 00023 void set(int idx, uint16_t x); 00024 /// Get waveform value for a specified data point 00025 /// @param idx The index of the data point in the #buffer, in the range 0..#buffer_size-1. 00026 /// @returns The value for the data point, in the range 0..65535. 00027 uint16_t operator[](const uint16_t idx); 00028 00029 /// Connect the D/A converter pin (enable output) 00030 void Connect(); 00031 /// Disconnect the D/A converter pin (pin becomes tri-state) 00032 void Disconnect(); 00033 00034 /// Reference to the DMA instance 00035 MODDMA& dma; 00036 00037 /// Set up the dma. 00038 /// Must set #buffer and #buffer_size first. 00039 void Setup(void); 00040 00041 /// Set waveform frequency 00042 /// @note Must set #buffer_size first. 00043 /// @param f Frequency of a complete cycle of the waveform (in Hz). 00044 void SetFrequency(float f); 00045 /// Read the actual waveform frequency that will be generated. 00046 float Frequency(); 00047 00048 /// Start generating the waveform (start dma) 00049 void Start(); 00050 /// Stop generating the waveform (but waits for the current cycle to complete) 00051 void Stop(); 00052 00053 private: 00054 MODDMA_Config conf; 00055 MODDMA_LLI lli; 00056 00057 /// ISR routine, called on Terminal Count 00058 void TC_callback(void); 00059 /// ISR routine, called on dma ERRor 00060 void ERR_callback(void); 00061 }; 00062 00063 #endif
Generated on Wed Jul 13 2022 02:11:02 by
1.7.2