TWI EEPROM PDC Example for SAM.
Copyright (c) 2016-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | AT24C_ADDRESS 0x40 |
Address of AT24C chips. More... | |
#define | EEPROM_MEM_ADDR 0 |
#define | EEPROM_MEM_ADDR_LENGTH 2 |
#define | STRING_EOL "\r" |
#define | STRING_HEADER |
#define | TEST_DATA_LENGTH (sizeof(test_data_tx)/sizeof(uint8_t)) |
Data to be sent. More... | |
#define | TWI_CLK 100000 |
TWI Bus Clock 100kHz. More... | |
#define | WAIT_TIME 10 |
EEPROM Wait Time. More... | |
Functions | |
void | BOARD_TWI_Handler (void) |
static void | configure_console (void) |
Configure the Console UART. More... | |
int | main (void) |
Application entry point for TWI EEPROM example. More... | |
static void | mdelay (uint32_t ul_dly_ticks) |
Wait for the given number of milliseconds (using the dwTimeStamp generated by the SAM microcontrollers' system tick). More... | |
void | SysTick_Handler (void) |
Handler for System Tick interrupt. More... | |
static void | twi_master_pdc_read (Twi *p_twi, twi_packet_t *p_packet) |
Read multiple bytes from a TWI compatible slave device. More... | |
static void | twi_master_pdc_write (Twi *p_twi, twi_packet_t *p_packet) |
Write multiple bytes to a TWI compatible slave device. More... | |
static uint32_t | twi_read_status (Twi *p_twi) |
Read status register. More... | |
Variables | |
Pdc * | g_p_twim_pdc |
volatile uint32_t | g_ul_ms_ticks = 0 |
Global timestamp in milliseconds since start of application. More... | |
static uint8_t | gs_uc_test_data_rx [TEST_DATA_LENGTH] = { 0 } |
Reception buffer. More... | |
twi_packet_t | packet_rx |
twi_packet_t | packet_tx |
Define TX and RX packet. More... | |
volatile uint32_t | Read_Interrupt_Flag = 0 |
static const volatile uint8_t | test_data_tx [] |
volatile uint32_t | Write_Interrupt_Flag = 0 |
Define interrupt flag. More... | |
#define AT24C_ADDRESS 0x40 |
Address of AT24C chips.
Referenced by main().
#define EEPROM_MEM_ADDR 0 |
Referenced by main().
#define EEPROM_MEM_ADDR_LENGTH 2 |
Referenced by main().
#define STRING_EOL "\r" |
#define STRING_HEADER |
Referenced by main().
#define TEST_DATA_LENGTH (sizeof(test_data_tx)/sizeof(uint8_t)) |
Data to be sent.
Referenced by main().
#define TWI_CLK 100000 |
TWI Bus Clock 100kHz.
Referenced by main().
#define WAIT_TIME 10 |
EEPROM Wait Time.
Referenced by main().
void BOARD_TWI_Handler | ( | void | ) |
References twi_disable_interrupt(), and twi_get_interrupt_mask().
|
static |
Configure the Console UART.
References uart_rs232_options::baudrate, stdio_serial_init(), and sysclk_enable_peripheral_clock().
Referenced by main().
int main | ( | void | ) |
Application entry point for TWI EEPROM example.
References twi_packet::addr, twi_packet::addr_length, AT24C_ADDRESS, board_init(), twi_packet::buffer, twi_packet::chip, configure_console(), EEPROM_MEM_ADDR, EEPROM_MEM_ADDR_LENGTH, gs_uc_test_data_rx, twi_packet::length, twi_options::master_clk, mdelay(), pmc_enable_periph_clk(), twi_options::speed, STRING_HEADER, sysclk_get_cpu_hz(), sysclk_get_peripheral_hz(), sysclk_init(), TEST_DATA_LENGTH, TWI_CLK, twi_get_pdc_base(), twi_master_init(), twi_master_pdc_read(), twi_master_pdc_write(), TWI_SUCCESS, and WAIT_TIME.
|
static |
Wait for the given number of milliseconds (using the dwTimeStamp generated by the SAM microcontrollers' system tick).
ul_dly_ticks | Delay to wait for, in milliseconds. |
References g_ul_ms_ticks.
Referenced by main().
void SysTick_Handler | ( | void | ) |
Handler for System Tick interrupt.
Process System Tick Event increments the timestamp counter.
|
static |
Read multiple bytes from a TWI compatible slave device.
p_twi | Pointer to a TWI instance. |
p_packet | Packet information and data (see twi_packet_t). |
References twi_packet::addr, twi_packet::addr_length, twi_packet::buffer, twi_packet::chip, twi_packet::length, NULL, pdc_disable_transfer(), pdc_enable_transfer(), pdc_rx_init(), twi_enable_interrupt(), twi_mk_addr(), twi_read_status(), pdc_packet::ul_addr, and pdc_packet::ul_size.
Referenced by main().
|
static |
Write multiple bytes to a TWI compatible slave device.
p_twi | Pointer to a TWI instance. |
p_packet | Packet information and data (see twi_packet_t). |
References twi_packet::addr, twi_packet::addr_length, twi_packet::buffer, twi_packet::chip, twi_packet::length, NULL, pdc_disable_transfer(), pdc_enable_transfer(), pdc_tx_init(), twi_enable_interrupt(), twi_mk_addr(), twi_read_status(), pdc_packet::ul_addr, and pdc_packet::ul_size.
Referenced by main().
|
inlinestatic |
Read status register.
p_twi | Pointer to an TWI instance. |
Referenced by twi_master_pdc_read(), and twi_master_pdc_write().
Pdc* g_p_twim_pdc |
volatile uint32_t g_ul_ms_ticks = 0 |
Global timestamp in milliseconds since start of application.
Referenced by delay_ms(), mdelay(), SysTick_Handler(), and toggle_led_test().
|
static |
Reception buffer.
Referenced by main().
twi_packet_t packet_rx |
Referenced by main().
twi_packet_t packet_tx |
Define TX and RX packet.
Referenced by main().
volatile uint32_t Read_Interrupt_Flag = 0 |
|
static |
volatile uint32_t Write_Interrupt_Flag = 0 |
Define interrupt flag.