Microchip® Advanced Software Framework

main.c File Reference

SAM EDBG TWI Information Interface Example.

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

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

Macros

#define EDBG_ADDRESS   0x28;
 EDBG TWI interface address. More...
 
#define EDBG_EXTEN_BOARDS_TOKEN   0xE1;
 Request token of EDBG TWI information interface. More...
 
#define EDBG_KIT_DATA_TOKEN   0xD2;
 
#define STRING_EOL   "\r"
 
#define STRING_HEADER
 
#define TIMEOUT   1000
 
#define TWI_CLK   400000
 TWI Bus Clock 400kHz. More...
 

Functions

static void configure_console (void)
 Configure the Console UART. More...
 
static void configure_i2c_master (void)
 Function for configuring I2C master module. More...
 
static void decode_board_info (uint8_t *buffer)
 Function for show the extension boards information. More...
 
int main (void)
 Main application. More...
 
static void show_extension_boards_information (void)
 Function for show the extension boards information. More...
 
static void show_kit_data (void)
 Function for show the kit data. More...
 

Variables

uint8_t extension_info [64]
 
uint8_t extension_map [2]
 Extension board info structure. More...
 
uint8_t kit_data [256]
 Kit data structure. More...
 
uint16_t maximum_voltage
 
uint16_t minimum_current
 
uint16_t minimum_voltage
 
twi_options_t opt
 I2C related structure. More...
 
twi_packet_t packet_rx
 
uint8_t read_buffer [1024]
 Read buffer. More...
 

#define EDBG_ADDRESS   0x28;

EDBG TWI interface address.

Referenced by show_extension_boards_information(), and show_kit_data().

#define EDBG_EXTEN_BOARDS_TOKEN   0xE1;

Request token of EDBG TWI information interface.

Referenced by show_extension_boards_information().

#define EDBG_KIT_DATA_TOKEN   0xD2;

Referenced by show_kit_data().

#define STRING_EOL   "\r"
#define STRING_HEADER
Value:
"-- EDBG TWI Information Interface Example --\r\n" \
"-- "BOARD_NAME" --\r\n" \
"-- Compiled: "__DATE__" "__TIME__" --"STRING_EOL
#define BOARD_NAME
Name of the board.
Definition: sam4e_xplained_pro.h:76
#define STRING_EOL
Definition: main.c:79

Referenced by main().

#define TIMEOUT   1000
#define TWI_CLK   400000

TWI Bus Clock 400kHz.

Referenced by configure_i2c_master().

static void configure_console ( void  )
static
static void configure_i2c_master ( void  )
static

Function for configuring I2C master module.

This function will configure the I2C master module with the SERCOM module to be used and pinmux settings

References EDBG_I2C_MODULE, EDBG_I2C_MODULE_ID, twi_options::master_clk, pmc_enable_periph_clk(), twi_options::speed, sysclk_get_cpu_hz(), TWI_CLK, twi_master_init(), and TWI_SUCCESS.

Referenced by main().

static void decode_board_info ( uint8_t *  buffer)
static

Function for show the extension boards information.

show extension boards information

References extension_info, maximum_voltage, minimum_current, and minimum_voltage.

Referenced by show_extension_boards_information().

static void show_extension_boards_information ( void  )
static

Function for show the extension boards information.

Get the extension boards info

Check and show info

show extension board info

References twi_packet::addr, twi_packet::addr_length, twi_packet::buffer, twi_packet::chip, decode_board_info(), EDBG_ADDRESS, EDBG_EXTEN_BOARDS_TOKEN, EDBG_I2C_MODULE, extension_map, twi_packet::length, read_buffer, TIMEOUT, twi_master_read(), and TWI_SUCCESS.

Referenced by main().

static void show_kit_data ( void  )
static

uint8_t extension_info[64]

Referenced by decode_board_info().

uint8_t extension_map[2]

Extension board info structure.

Referenced by show_extension_boards_information().

uint8_t kit_data[256]

Kit data structure.

Referenced by show_kit_data().

uint16_t maximum_voltage

Referenced by decode_board_info().

uint16_t minimum_current

Referenced by decode_board_info().

uint16_t minimum_voltage

Referenced by decode_board_info().

I2C related structure.

twi_packet_t packet_rx
uint8_t read_buffer[1024]

Read buffer.

Referenced by show_extension_boards_information().