Microchip® Advanced Software Framework

sercom.c File Reference

SAM Serial Peripheral Interface Driver.

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

#include "sercom.h"

Macros

#define _SERCOM_PAD_DEFAULTS_CASE(n, pad)
 
#define BAUD_FP_MAX   8
 
#define BAUD_INT_MAX   8192
 
#define SHIFT   32
 

Functions

uint32_t _sercom_get_default_pad (Sercom *const sercom_module, const uint8_t pad)
 
uint8_t _sercom_get_sercom_inst_index (Sercom *const sercom_instance)
 
enum status_code sercom_set_gclk_generator (const enum gclk_generator generator_source, const bool force_change)
 Set GCLK channel to generator. More...
 

#define _SERCOM_PAD_DEFAULTS_CASE (   n,
  pad 
)
Value:
case (uintptr_t)SERCOM##n: \
switch (pad) { \
case 0: \
return SERCOM##n##_PAD0_DEFAULT; \
case 1: \
return SERCOM##n##_PAD1_DEFAULT; \
case 2: \
return SERCOM##n##_PAD2_DEFAULT; \
case 3: \
return SERCOM##n##_PAD3_DEFAULT; \
} \
break;
static struct uip_ds6_notification n
Definition: simple-rpl.c:48

Creates a switch statement case entry to convert a SERCOM instance and pad index to the default SERCOM pad MUX setting.

Referenced by _sercom_get_default_pad().

#define BAUD_FP_MAX   8
#define BAUD_INT_MAX   8192
#define SHIFT   32

uint32_t _sercom_get_default_pad ( Sercom *const  sercom_module,
const uint8_t  pad 
)

Gets the default PAD pinout for a given SERCOM.

Returns the pinmux settings for the given SERCOM and pad. This is used for default configuration of pins.

Parameters
[in]sercom_modulePointer to the SERCOM module
[in]padPAD to get default pinout for
Returns
The default pinmux for the given SERCOM instance and PAD

References _SERCOM_PAD_DEFAULTS_CASE, Assert, and MREPEAT.

Referenced by _i2c_slave_set_config(), _spi_check_config(), _spi_set_config(), dbg_init(), and usart_init().

uint8_t _sercom_get_sercom_inst_index ( Sercom *const  sercom_instance)

Find index of given instance.

Parameters
[in]sercom_instanceInstance pointer.
Returns
Index of given instance.

References Assert, and i.

Referenced by _sercom_get_interrupt_vector(), _spi_set_config(), _usart_set_config(), cdc_rx_init(), dbg_init(), i2c_master_init(), i2c_slave_init(), spi_init(), spi_master_vec_init(), spi_set_baudrate(), and usart_init().

enum status_code sercom_set_gclk_generator ( const enum gclk_generator  generator_source,
const bool  force_change 
)

Set GCLK channel to generator.

This will set the appropriate GCLK channel to the requested GCLK generator. This will set the generator for all SERCOM instances, and the user will thus only be able to set the same generator that has previously been set, if any.

After the generator has been set the first time, the generator can be changed using the force_change flag.

Parameters
[in]generator_sourceThe generator to use for SERCOM.
[in]force_changeForce change the generator.
Returns
Status code indicating the GCLK generator change operation.
Return values
STATUS_OKIf the generator update request was successful.
STATUS_ERR_ALREADY_INITIALIZEDIf a generator was already configured and the new configuration was not forced.

References SERCOM_GCLK_ID, system_gclk_chan_config::source_generator, STATUS_ERR_ALREADY_INITIALIZED, STATUS_OK, system_gclk_chan_enable(), system_gclk_chan_get_config_defaults(), and system_gclk_chan_set_config().

Referenced by dbg_init(), i2c_master_init(), i2c_slave_init(), spi_init(), spi_master_vec_init(), and usart_init().