#include "print_funcs.h"
#include "board.h"
#include "power_clocks_lib.h"
#include "twis.h"
#include "gpio.h"
#include <stdint.h>
#include <stdio.h>
Macros | |
System Clock Frequencies | |
Information about Clock configuration and TWIM Module configuration | |
#define | DFLL_FREQ_HZ 96000000 |
TWIM Module Configuration | |
Information about TWIM Module | |
#define | TWIS (&AVR32_TWIS0) |
#define | SLAVE_ADDRESS 0x05 |
#define | SLAVE_ADDR_LGT 3 |
#define | VIRTUALMEM_ADDR_START 0x123456 |
#define | TWI_SPEED 50000 |
Virtual Memory Management | |
Defines to manage a virtual TWI memory | |
#define | TWI_MEM_SIZE 20 |
#define | TWI_MEM_IDLE 0 |
#define | TWI_MEM_ADDR 1 |
#define | TWI_MEM_DATA 2 |
Functions | |
void | twis_slave_rx (uint8_t u8_value) |
Manage the received data on TWI. More... | |
uint8_t | twis_slave_tx (void) |
Transmit a data on TWIS. More... | |
void | twis_slave_stop () |
Manage stop transfer reception on TWIS. More... | |
static void | init_sys_clocks (void) |
Initializes the MCU system clocks. More... | |
void | twis_init (void) |
TWIS interface initialization. More... | |
int | main (void) |
Main function. More... | |
Variables | |
uint8_t | s_memory [TWI_MEM_SIZE] = { 0 } |
Content of the Virtual mem. More... | |
uint8_t | s_status_cmd = TWI_MEM_IDLE |
State variable. More... | |
uint32_t | s_u32_addr |
The current address in the virtual mem. More... | |
uint8_t | s_u8_addr_pos |
Offset in the address value (because we receive the address one Byte at a time) More... | |
System Clock Frequencies | |
Information about Clock configuration and TWIM Module configuration | |
#define | FCPU_HZ 12000000 |
#define | FPBA_HZ 12000000 |
#define | TEST_TWIS_TWCK_PIN AVR32_TWIMS0_TWCK_0_0_PIN |
#define | TEST_TWIS_TWCK_FUNCTION AVR32_TWIMS0_TWCK_0_0_FUNCTION |
#define | TEST_TWIS_TWD_PIN AVR32_TWIMS0_TWD_0_2_PIN |
#define | TEST_TWIS_TWD_FUNCTION AVR32_TWIMS0_TWD_0_2_FUNCTION |
static scif_gclk_opt_t | gc_dfllif_ref_opt = { SCIF_GCCTRL_SLOWCLOCK, 0, false} |
static pcl_freq_param_t | pcl_freq_param |
#define DFLL_FREQ_HZ 96000000 |
#define FCPU_HZ 12000000 |
#define FPBA_HZ 12000000 |
#define SLAVE_ADDR_LGT 3 |
#define SLAVE_ADDRESS 0x05 |
#define TEST_TWIS_TWCK_FUNCTION AVR32_TWIMS0_TWCK_0_0_FUNCTION |
#define TEST_TWIS_TWCK_PIN AVR32_TWIMS0_TWCK_0_0_PIN |
#define TEST_TWIS_TWD_FUNCTION AVR32_TWIMS0_TWD_0_2_FUNCTION |
#define TEST_TWIS_TWD_PIN AVR32_TWIMS0_TWD_0_2_PIN |
PIN 1 & 2 in Header J44 can be used in UC3L_EK
#define TWI_MEM_ADDR 1 |
#define TWI_MEM_DATA 2 |
#define TWI_MEM_IDLE 0 |
#define TWI_MEM_SIZE 20 |
#define TWI_SPEED 50000 |
#define TWIS (&AVR32_TWIS0) |
#define VIRTUALMEM_ADDR_START 0x123456 |
|
static |
Initializes the MCU system clocks.
int main | ( | void | ) |
Main function.
void twis_init | ( | void | ) |
TWIS interface initialization.
For UC3L devices, TWI default pins are, TWIMS0 -> PB05,PA21 TWIMS1 -> PB04 To enable TWI clock/data in another pin, these have to be assigned to other peripherals or as GPIO.
void twis_slave_rx | ( | uint8_t | u8_value | ) |
Manage the received data on TWI.
void twis_slave_stop | ( | ) |
Manage stop transfer reception on TWIS.
uint8_t twis_slave_tx | ( | void | ) |
Transmit a data on TWIS.
|
static |
|
static |
uint8_t s_memory[TWI_MEM_SIZE] = { 0 } |
Content of the Virtual mem.
uint8_t s_status_cmd = TWI_MEM_IDLE |
State variable.
uint32_t s_u32_addr |
The current address in the virtual mem.
uint8_t s_u8_addr_pos |
Offset in the address value (because we receive the address one Byte at a time)