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
static status_code_t init_test ( void  )
static

Initialize the TWIM module.

Returns
STATUS_OK if the initialization succeeds, error code otherwise.

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

Referenced by main().

twi_package_t packet_rx

Referenced by read_test_pdca().

twi_package_t packet_tx

TWI data package.

Referenced by write_test_pdca().

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_pdca_example.c:86
#define PDCA_PID_TWIM1_RX
Definition: twim_pdca_example.c:186
#define PATTERN_TEST_LENGTH
Definition: twim_pdca_example.c:81
const pdca_channel_config_t PDCA_TX_CONFIGS
static
Initial value:
= {
.addr = (void *)write_data,
.r_addr = 0,
.r_size = 0,
.ring = false,
.transfer_size = PDCA_MR_SIZE_BYTE
}
#define PATTERN_TEST_LENGTH
Definition: twim_pdca_example.c:81
uint8_t write_data[PATTERN_TEST_LENGTH+TARGET_ADDR_LGT]
Array to store the test data for sending.
Definition: twim_pdca_example.c:84
#define TARGET_ADDR_LGT
Internal Address length.
Definition: conf_example.h:56
#define PDCA_PID_TWIM1_TX
Definition: twim_pdca_example.c:144
uint8_t read_data[PATTERN_TEST_LENGTH]

Array to store the received test data.

Referenced by main(), and read_test_pdca().

uint8_t write_data[PATTERN_TEST_LENGTH+TARGET_ADDR_LGT]

Array to store the test data for sending.

Referenced by write_test_pdca().