Microchip® Advanced Software Framework

twim_pdca_example.c File Reference

TWIM PDCA Example for SAM.

Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.

#include <asf.h>
#include <string.h>
#include "conf_example.h"

Macros

#define PATTERN_TEST   "SAM4L TWIM PDCA Example"
 
#define PATTERN_TEST_LENGTH   (sizeof(PATTERN_TEST)/sizeof(uint8_t))
 
#define PDCA_PID_TWIM1_RX   6
 
#define PDCA_PID_TWIM1_TX   24
 
#define PDCA_RX_CHANNEL   1
 
#define PDCA_TX_CHANNEL   0
 

Functions

static void configure_console (void)
 Configure serial console. More...
 
static status_code_t init_test (void)
 Initialize the TWIM module. More...
 
static void read_test_pdca (void)
 
static void write_test_pdca (void)
 
int main (void)
 

Variables

twi_package_t packet_rx
 
twi_package_t packet_tx
 TWI data package. More...
 
static const pdca_channel_config_t PDCA_RX_CONFIGS
 
static const pdca_channel_config_t PDCA_TX_CONFIGS
 
uint8_t read_data [PATTERN_TEST_LENGTH]
 Array to store the received test data. More...
 
uint8_t write_data [PATTERN_TEST_LENGTH+TARGET_ADDR_LGT]
 Array to store the test data for sending. More...
 

#define PATTERN_TEST   "SAM4L TWIM PDCA Example"

Referenced by main(), and write_test_pdca().

#define PATTERN_TEST_LENGTH   (sizeof(PATTERN_TEST)/sizeof(uint8_t))
#define PDCA_PID_TWIM1_RX   6
#define PDCA_PID_TWIM1_TX   24
#define PDCA_RX_CHANNEL   1

Referenced by read_test_pdca().

#define PDCA_TX_CHANNEL   0

Referenced by write_test_pdca().

static void configure_console ( void  )
static

Configure serial console.

References uart_rs232_options::baudrate, and stdio_serial_init().

Referenced by main().

static status_code_t init_test ( void  )
static

Initialize the TWIM module.

Returns
STATUS_OK if the initialization succeeds, error code otherwise.

References cpu_speed, sysclk_get_peripheral_bus_hz(), twim_config::twim_clk, twim_default_callback(), twim_set_callback(), and twim_set_config().

Referenced by main().

twi_package_t packet_rx
twi_package_t packet_tx

TWI data package.

const pdca_channel_config_t PDCA_RX_CONFIGS
static
Initial value:
= {
.addr = (void *)read_data,
.r_addr = 0,
.r_size = 0,
.ring = false,
.transfer_size = PDCA_MR_SIZE_BYTE
}
uint8_t read_data[PATTERN_TEST_LENGTH]
Array to store the received test data.
Definition: twim_example.c:89
#define PDCA_PID_TWIM1_RX
Definition: twim_pdca_example.c:186
#define PATTERN_TEST_LENGTH
Definition: twim_pdca_example.c:81

Referenced by adc_pdca_set_config().

const pdca_channel_config_t PDCA_TX_CONFIGS
static
Initial value:
= {
.addr = (void *)write_data,
.size = PATTERN_TEST_LENGTH + TARGET_ADDR_LGT,
.r_addr = 0,
.r_size = 0,
.ring = false,
.transfer_size = PDCA_MR_SIZE_BYTE
}
const uint8_t write_data[]
Array to store the test data for sending.
Definition: twim_example.c:84
#define PATTERN_TEST_LENGTH
Definition: twim_pdca_example.c:81
#define PDCA_PID_TWIM1_TX
Definition: twim_pdca_example.c:144

Referenced by adc_pdca_set_config().

uint8_t read_data[PATTERN_TEST_LENGTH]

Array to store the received test data.

uint8_t write_data[PATTERN_TEST_LENGTH+TARGET_ADDR_LGT]

Array to store the test data for sending.