SAM4SD32 (SAM4S-EK2)
Loading...
Searching...
No Matches
twi_master.h File Reference

TWI Master driver for SAM. More...

#include "twi.h"
#include "sysclk.h"

Go to the source code of this file.

Macros

#define twi_master_disable(p_twi)
#define twi_master_enable(p_twi)

Typedefs

typedef twi_options_t twi_master_options_t
typedef Twitwi_master_t
 This type can be used independently to refer to TWI master module for the architecture used.
typedef twi_packet_t twi_package_t

Functions

static uint32_t twi_master_setup (twi_master_t p_twi, twi_master_options_t *p_opt)

Detailed Description

TWI Master driver for SAM.

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

\cond ASF_LICENSE

Definition in file sam_twi/twi_master.h.

Macro Definition Documentation

◆ twi_master_disable

#define twi_master_disable ( p_twi)
Value:
void twi_disable_master_mode(Twi *p_twi)
Disable TWI master mode.
Definition twi.c:104

Definition at line 95 of file sam_twi/twi_master.h.

◆ twi_master_enable

#define twi_master_enable ( p_twi)
Value:
void twi_enable_master_mode(Twi *p_twi)
Enable TWI master mode.
Definition twi.c:89

Definition at line 94 of file sam_twi/twi_master.h.

Typedef Documentation

◆ twi_master_options_t

Definition at line 44 of file sam_twi/twi_master.h.

◆ twi_package_t

Definition at line 45 of file sam_twi/twi_master.h.

Function Documentation

◆ twi_master_setup()

uint32_t twi_master_setup ( twi_master_t p_twi,
twi_master_options_t * p_opt )
inlinestatic

Definition at line 47 of file sam_twi/twi_master.h.

49{
50 p_opt->master_clk = sysclk_get_peripheral_hz();
51 p_opt->smbus = 0;
52#if SAMG55
53 if (p_twi == TWI0) {
54 sysclk_enable_peripheral_clock(ID_FLEXCOM0);
55 } else if (p_twi == TWI1) {
56 sysclk_enable_peripheral_clock(ID_FLEXCOM1);
57 } else if (p_twi == TWI2) {
58 sysclk_enable_peripheral_clock(ID_FLEXCOM2);
59 } else if (p_twi == TWI3) {
60 sysclk_enable_peripheral_clock(ID_FLEXCOM3);
61 } else if (p_twi == TWI4) {
62 sysclk_enable_peripheral_clock(ID_FLEXCOM4);
63 } else if (p_twi == TWI5) {
64 sysclk_enable_peripheral_clock(ID_FLEXCOM5);
65 } else if (p_twi == TWI6) {
66 sysclk_enable_peripheral_clock(ID_FLEXCOM6);
67#ifdef _SAMG55_FLEXCOM7_INSTANCE_
68 } else if (p_twi == TWI7) {
69 sysclk_enable_peripheral_clock(ID_FLEXCOM7);
70#endif /* _SAMG55_FLEXCOM7_INSTANCE_*/
71 } else {
72 // Do Nothing
73 }
74#else
75#if (!(SAMG51 || SAMG53 || SAMG54))
76 if (p_twi == TWI0) {
77 sysclk_enable_peripheral_clock(ID_TWI0);
78 } else
79#endif
80 if (p_twi == TWI1) {
81 sysclk_enable_peripheral_clock(ID_TWI1);
82#if (SAM4N || SAMG)
83 } else if (p_twi == TWI2) {
84 sysclk_enable_peripheral_clock(ID_TWI2);
85#endif
86 } else {
87 // Do Nothing
88 }
89#endif
90
91 return (twi_master_init(p_twi, p_opt));
92}
uint32_t twi_master_init(Twi *p_twi, const twi_options_t *p_opt)
Initialize TWI master mode.
Definition twi.c:118
#define TWI0
(TWI0 ) Base Address
Definition sam4sd32c.h:419
#define ID_TWI1
Two Wire Interface 1 (TWI1).
Definition sam4sd32c.h:338
#define TWI1
(TWI1 ) Base Address
Definition sam4sd32c.h:421
#define ID_TWI0
Two Wire Interface 0 (TWI0).
Definition sam4sd32c.h:337
uint8_t smbus
SMBUS mode (set 1 to use SMBUS quick command, otherwise don't).
Definition twi.h:82
uint32_t master_clk
MCK for TWI.
Definition twi.h:76

References ID_TWI0, ID_TWI1, twi_options::master_clk, twi_options::smbus, TWI0, TWI1, and twi_master_init().