#include <avr32/io.h>
#include "compiler.h"
#include "board.h"
#include "dsp.h"
#include "pm.h"
#include "gpio.h"
#include "usart.h"
#include "intc.h"
#include "pwm.h"
#include "flashc.h"
#include "preprocessor.h"
#include "adc.h"
#include "tc.h"
#include "pdca.h"
Macros | |
#define | ADC_CHANNEL 1 |
ADC channel. More... | |
#define | AVR32_PDCA_PID_USART_TX AVR32_PDCA_PID_USART1_TX |
#define | BUFFER_SIZE (252*4) |
The size of the buffer. More... | |
#define | CP_PBA_SPEED 12000000 |
The clock frequency. More... | |
#define | EXAMPLE_USART (&AVR32_USART1) |
#define | EXAMPLE_USART_RX_FUNCTION AVR32_USART1_RXD_0_0_FUNCTION |
#define | EXAMPLE_USART_RX_PIN AVR32_USART1_RXD_0_0_PIN |
#define | EXAMPLE_USART_TX_FUNCTION AVR32_USART1_TXD_0_0_FUNCTION |
#define | EXAMPLE_USART_TX_PIN AVR32_USART1_TXD_0_0_PIN |
#define | NB_BUFFERS 2 |
Number of buffers. More... | |
#define | PDCA_ADC_CHANNEL 0 |
PDCA channel for the ADC. More... | |
#define | PDCA_USART_CHANNEL 1 |
PDCA channel for the USART. More... | |
#define | STATE_GET_SAMPLES 2 |
#define | STATE_SEND_USART 1 |
#define | TC_CHANNEL 0 |
Timer Counter channel. More... | |
Enumerations | |
enum | { BUFFER_STATE_FREE = 0, BUFFER_STATE_BUSY = 1, BUFFER_STATE_FILLED = 2 } |
Functions | |
void | init_adc () |
void | init_pdca_adc () |
void | init_pdca_usart () |
void | init_tc (int rate) |
void | init_usart () |
this function initializes the USART module at 115200 bauds More... | |
int | main (int argc, char *argv[]) |
The main function. More... | |
static void | pdca_adc_interrupt_handler (void) |
static void | pdca_usart_interrupt_handler (void) |
void | sys_cpu_48MHz (void) |
To set the clock frequency to 48MHz. More... | |
Variables | |
A_ALIGNED char | buffer [NB_BUFFERS][BUFFER_SIZE] |
The main buffer. More... | |
enum { ... } | buffer_state [NB_BUFFERS] |
int | i_r |
int | i_w |
char * | pbuffer_r |
char * | pbuffer_w |
return | |
Low-level initialization routine called during startup, before the main function. More... | |
volatile int | state |
state machine variable More... | |
A_ALIGNED char | tbuffer [BUFFER_SIZE/4+4] |
Transfer buffer. More... | |
#define ADC_CHANNEL 1 |
ADC channel.
Referenced by init_adc().
#define AVR32_PDCA_PID_USART_TX AVR32_PDCA_PID_USART1_TX |
Referenced by init_pdca_usart(), and main().
#define BUFFER_SIZE (252*4) |
The size of the buffer.
Referenced by main().
#define CP_PBA_SPEED 12000000 |
The clock frequency.
Referenced by init_tc(), and init_usart().
#define EXAMPLE_USART (&AVR32_USART1) |
Referenced by init_usart().
#define EXAMPLE_USART_RX_FUNCTION AVR32_USART1_RXD_0_0_FUNCTION |
Referenced by init_usart().
#define EXAMPLE_USART_RX_PIN AVR32_USART1_RXD_0_0_PIN |
Referenced by init_usart().
#define EXAMPLE_USART_TX_FUNCTION AVR32_USART1_TXD_0_0_FUNCTION |
Referenced by init_usart().
#define EXAMPLE_USART_TX_PIN AVR32_USART1_TXD_0_0_PIN |
Referenced by init_usart().
#define NB_BUFFERS 2 |
Number of buffers.
Referenced by main(), pdca_adc_interrupt_handler(), and pdca_usart_interrupt_handler().
#define PDCA_ADC_CHANNEL 0 |
PDCA channel for the ADC.
Referenced by init_pdca_adc(), main(), and pdca_adc_interrupt_handler().
#define PDCA_USART_CHANNEL 1 |
PDCA channel for the USART.
Referenced by init_pdca_usart(), main(), and pdca_usart_interrupt_handler().
#define STATE_GET_SAMPLES 2 |
Referenced by main(), and pdca_adc_interrupt_handler().
#define STATE_SEND_USART 1 |
Referenced by main(), and pdca_adc_interrupt_handler().
#define TC_CHANNEL 0 |
Timer Counter channel.
Referenced by init_adc(), init_tc(), init_timer_isr(), and ISR().
void init_adc | ( | ) |
References ADC_CHANNEL, adc_configure(), adc_enable(), ADC_GPIO_MAP, ATPASTE3, gpio_enable_module(), and TC_CHANNEL.
Referenced by main().
void init_pdca_adc | ( | ) |
References pdca_channel_options_t::addr, ATPASTE2, buffer, INTC_register_interrupt(), NULL, PDCA_ADC_CHANNEL, pdca_adc_interrupt_handler(), pdca_init_channel(), and PDCA_TRANSFER_SIZE_HALF_WORD.
Referenced by main().
void init_pdca_usart | ( | ) |
References pdca_channel_options_t::addr, ATPASTE2, AVR32_PDCA_PID_USART_TX, buffer, INTC_register_interrupt(), NULL, pdca_init_channel(), PDCA_TRANSFER_SIZE_BYTE, PDCA_USART_CHANNEL, and pdca_usart_interrupt_handler().
Referenced by main().
void init_tc | ( | int | rate | ) |
References tc_waveform_opt_t::channel, CP_PBA_SPEED, FALSE, TC_CHANNEL, TC_CLOCK_SOURCE_TC2, TC_EVT_EFFECT_NOOP, TC_EVT_EFFECT_TOGGLE, tc_init_waveform(), TC_SEL_NO_EDGE, tc_start(), TC_WAVEFORM_SEL_UP_MODE_RC_TRIGGER, and tc_write_rc().
Referenced by main().
void init_usart | ( | ) |
this function initializes the USART module at 115200 bauds
References usart_options_t::baudrate, CP_PBA_SPEED, EXAMPLE_USART, EXAMPLE_USART_RX_FUNCTION, EXAMPLE_USART_RX_PIN, EXAMPLE_USART_TX_FUNCTION, EXAMPLE_USART_TX_PIN, gpio_enable_module(), USART_1_STOPBIT, usart_init_rs232(), USART_NO_PARITY, and USART_NORMAL_CHMODE.
Referenced by main().
int main | ( | int | argc, |
char * | argv[] | ||
) |
The main function.
References adc_start(), buffer, BUFFER_SIZE, buffer_state, BUFFER_STATE_BUSY, BUFFER_STATE_FILLED, BUFFER_STATE_FREE, Disable_global_interrupt, dsp_adpcm_ima_encode(), Enable_global_interrupt, flashc_set_wait_state(), i, i_r, i_w, init_adc(), init_pdca_adc(), init_pdca_usart(), init_tc(), init_usart(), INTC_init_interrupts(), NB_BUFFERS, pbuffer_r, pbuffer_w, PDCA_ADC_CHANNEL, pdca_enable(), pdca_enable_interrupt_transfer_complete(), pdca_reload_channel(), PDCA_USART_CHANNEL, predicted_value, state, STATE_GET_SAMPLES, STATE_SEND_USART, step_index, sys_cpu_48MHz(), and tbuffer.
|
static |
References buffer, buffer_state, BUFFER_STATE_FILLED, i_w, NB_BUFFERS, pbuffer_w, PDCA_ADC_CHANNEL, pdca_disable_interrupt_transfer_complete(), state, STATE_GET_SAMPLES, and STATE_SEND_USART.
Referenced by init_pdca_adc().
|
static |
References buffer, buffer_state, BUFFER_STATE_FREE, i_r, NB_BUFFERS, pbuffer_r, pdca_disable_interrupt_transfer_complete(), and PDCA_USART_CHANNEL.
Referenced by init_pdca_usart().
void sys_cpu_48MHz | ( | void | ) |
To set the clock frequency to 48MHz.
References FOSC0, OSC0_STARTUP, pm_cksel(), pm_pll_enable(), pm_pll_set_option(), pm_pll_setup(), pm_switch_to_clock(), pm_switch_to_osc0(), pm_wait_for_pll0_locked(), and TRUE.
Referenced by main().
A_ALIGNED char buffer[NB_BUFFERS][BUFFER_SIZE] |
The main buffer.
Referenced by audio_mixer_get_buffer_direct(), compress_first_pass(), compress_output(), consume_data(), d2i_RSA_PUBKEY(), dac_sample_sent_cb(), decompress_data(), decompress_smooth_data(), fifo_init(), init_pdca(), init_pdca_adc(), init_pdca_usart(), jinit_c_coef_controller(), jinit_d_coef_controller(), main(), mxt_probe_device(), output_message(), pdca_adc_interrupt_handler(), pdca_interrupt_handler(), pdca_usart_interrupt_handler(), qt_write_regs(), transencode_coef_controller(), ucvector_init_buffer(), usb_stream_input(), and virtual_usb_trans().
enum { ... } buffer_state[NB_BUFFERS] |
Referenced by main(), pdca_adc_interrupt_handler(), and pdca_usart_interrupt_handler().
int i_r |
Referenced by main(), and pdca_usart_interrupt_handler().
int i_w |
Referenced by main(), and pdca_adc_interrupt_handler().
char* pbuffer_r |
Referenced by main(), pdca_usart_interrupt_handler(), and set_new_dac_buffer().
char* pbuffer_w |
Referenced by main(), pdca_adc_interrupt_handler(), and pdca_interrupt_handler().
return |
Low-level initialization routine called during startup, before the main function.
volatile int state |
state machine variable
Referenced by ai_usb_ms_audio_nav_mov(), cmd_ping(), console_schedule_cmd(), decode_mcu(), decode_mcu_DC_first(), main(), navauto_mov_explorer(), navauto_mov_playlist(), navauto_open(), navauto_setpos(), netif_add(), pdca_adc_interrupt_handler(), and sd_mmc_select_slot().
A_ALIGNED char tbuffer[BUFFER_SIZE/4+4] |
Transfer buffer.
Referenced by main().