Microchip® Advanced Software Framework

sercom.h File Reference

SAM Serial Peripheral Interface Driver.

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

#include <compiler.h>
#include <system.h>
#include <clock.h>
#include <system_interrupt.h>
#include "sercom_pinout.h"

Macros

#define FEATURE_SERCOM_SYNCBUSY_SCHEME_VERSION_1
 
#define SERCOM_GCLK_ID   SERCOM0_GCLK_ID_SLOW
 

Enumerations

enum  sercom_asynchronous_operation_mode {
  SERCOM_ASYNC_OPERATION_MODE_ARITHMETIC = 0,
  SERCOM_ASYNC_OPERATION_MODE_FRACTIONAL
}
 sercom asynchronous operation mode More...
 
enum  sercom_asynchronous_sample_num {
  SERCOM_ASYNC_SAMPLE_NUM_3 = 3,
  SERCOM_ASYNC_SAMPLE_NUM_8 = 8,
  SERCOM_ASYNC_SAMPLE_NUM_16 = 16
}
 sercom asynchronous samples per bit More...
 

Functions

enum status_code _sercom_get_async_baud_val (const uint32_t baudrate, const uint32_t peripheral_clock, uint16_t *const baudval, enum sercom_asynchronous_operation_mode mode, enum sercom_asynchronous_sample_num sample_num)
 
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_get_sync_baud_val (const uint32_t baudrate, const uint32_t external_clock, uint16_t *const baudval)
 
enum status_code sercom_set_gclk_generator (const enum gclk_generator generator_source, const bool force_change)
 Set GCLK channel to generator. More...
 

#define FEATURE_SERCOM_SYNCBUSY_SCHEME_VERSION_1
#define SERCOM_GCLK_ID   SERCOM0_GCLK_ID_SLOW

sercom asynchronous operation mode

Select sercom asynchronous operation mode

Enumerator
SERCOM_ASYNC_OPERATION_MODE_ARITHMETIC 
SERCOM_ASYNC_OPERATION_MODE_FRACTIONAL 

sercom asynchronous samples per bit

Select number of samples per bit

Enumerator
SERCOM_ASYNC_SAMPLE_NUM_3 
SERCOM_ASYNC_SAMPLE_NUM_8 
SERCOM_ASYNC_SAMPLE_NUM_16 

enum status_code _sercom_get_async_baud_val ( const uint32_t  baudrate,
const uint32_t  peripheral_clock,
uint16_t *const  baudval,
enum sercom_asynchronous_operation_mode  mode,
enum sercom_asynchronous_sample_num  sample_num 
)

Referenced by _usart_set_config().

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 _spi_set_config(), 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.

Referenced by _sercom_get_interrupt_vector(), _spi_set_config(), _usart_set_config(), spi_init(), spi_set_baudrate(), and usart_init().

enum status_code _sercom_get_sync_baud_val ( const uint32_t  baudrate,
const uint32_t  external_clock,
uint16_t *const  baudval 
)
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 spi_init(), and usart_init().