MEGA-1284P Xplained Example Application
Functions | Variables

Initialization driver

Functions

void io_init_terminal_mode (void)
 Function to setup IO for terminal mode.
void io_init_demo_mode (void)
 Function to setup IO for demo mode.
void power_reduction_enable (void)
 Function to reduce power consumption.
void usart1_init (void)
 Function to setup USART1.
void adc_init (void)
 Function to setup ADC.
void timer1_lightdemo_init (void)
 Function to setup timer1 for light sensor demo.
void stop_timer1_lightdemo (void)
 Function to stop timer1 used in the light sensor demo.
void timer1_init (void)
 Function to setup timer1 as a time base for the touch lib.
void qt_set_parameters (void)
 Function to set values for touch sensing.
void touch_init (void)
 Function to setup touch button.

Variables

TOUCH_DATA_T SNS_array [2][2]
TOUCH_DATA_T SNSK_array [2][2]

Detailed Description

The init driver is used to initialize IO (demo or terminal mode), power reduction features, USART1, ADC, Timer1 (demo or terminal mode) and touch sensing (QTB0)


Function Documentation

void adc_init ( void  )

Function to setup ADC.

ADC configuration:

  • Internal 2.56V bandgap voltage with 100nF cap at AREF pin as reference
  • 172.8kHz ADC frequency
void io_init_demo_mode ( void  )

Function to setup IO for demo mode.

Configure all I/O as input pull-up enabled to make sure all I/Os have a defined level. Light sensor and NTC sensor (PA6 and PA7): input pull-up disable. Enable pinchange interrupt for SW0:2 used to toggle through operating modes

void io_init_terminal_mode ( void  )

Function to setup IO for terminal mode.

Configure all I/O as input pull-up enabled to make sure all I/Os have a defined level except LEDs (PB3:0) which is configured as outputs. Light sensor and NTC sensor (PA6 and PA7): input pull-up disable.

void power_reduction_enable ( void  )

Function to reduce power consumption.

This function will turn off clocks to all IO modules except for Timer2 which is used in power-save mode. The function will also shutdown analog modules like the AC and ADC.

void qt_set_parameters ( void  )

Function to set values for touch sensing.

The function will fill the default threshold values in the configuration data structure. The user can change the values of these parameters to fit the application.

void stop_timer1_lightdemo ( void  )

Function to stop timer1 used in the light sensor demo.

All timer1 registers are set to default state

void timer1_init ( void  )

Function to setup timer1 as a time base for the touch lib.

In this mode Timer1 is used to generate PWM signal on the LEDs.

Timer1 configuration:

  • CTC mode (clear on compare match A)
  • clkIO/8 prescaling
void timer1_lightdemo_init ( void  )

Function to setup timer1 for light sensor demo.

In this mode Timer1 is used to generate PWM signal on the LEDs.

Timer1 configuration:

  • Fast PWM
  • Clear OC1B on compare match, set OC1B at bottom (non-inverting mode)
  • clkIO/8 prescaling
  • ICR1 set as TOP
  • Output compare match B and timer1 overflow interrupts enabled
void touch_init ( void  )

Function to setup touch button.

This function will configure touch sensing for the QTB0 touch button. LED1 is used as touch indication. Touch detected: LED1 on, touch not detected: LED1 off.

void usart1_init ( void  )

Function to setup USART1.

USART1 is used to communicate with the boardcontroller (AT32UC3256B1).

USART1 configuration:

  • 57600 baud
  • No parity
  • 1 stop bit
  • 8-bit character size

Variable Documentation

TOUCH_DATA_T SNS_array[2][2]
TOUCH_DATA_T SNSK_array[2][2]
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines