sarmfsw: SMFSW Toolbox (desinged for ARM / compatible with other 8b/16b/32b platforms) 4.0rc
SMFSW collection of miscellaneous functions \& macros (desinged for ARM / compatible with other 8b/16b/32b platforms)
Loading...
Searching...
No Matches
arm_chip_sam.h File Reference

ARM common macros for Atmel SAM families. More...

#include "atmel_start_pins.h"
#include "err_codes.h"
#include "hpl_reset.h"
#include <ARM_CMSIS_INC>
Include dependency graph for arm_chip_sam.h:

Macros

#define SAM_HEADER(f)
 concatenate <hri_(f).h> name following sam family f
 
#define SAM_CONF_HEADER(f)
 <sam.h> name following sam family f
 
#define ARM_CMSIS_INC   SAM_HEADER(SAM_FAMILY)
 Alias for SAM CMSIS include.
 
#define ARM_HAL_CFG   SAM_CONF_HEADER(SAM_FAMILY)
 Alias for SAM HAL config include.
 
#define HAL_MAX_TICKS   ((uint32_t) -1)
 HAL max Ticks value.
 
#define HAL_MS_TICKS_FACTOR   1U
 HAL milliseconds multiplier (depending tick counter frequency)
 

Enumerations

enum  eResetSource {
  RST_POR = RESET_REASON_POR , RST_BODCORE = RESET_REASON_BODCORE , RST_BODVDD = RESET_REASON_BODVDD , RST_EXT = RESET_REASON_EXT ,
  RST_WDT = RESET_REASON_WDT , RST_SYST = RESET_REASON_SYST , RST_UNKNOWN = 0xFFU
}
 Source of last reset. More...
 

Detailed Description

ARM common macros for Atmel SAM families.

Author
SMFSW
MISRA C:2012 Deviations
Header scope legitimate use derogation authorized for:
Rule-5.6 - Required: unique typedef name (misra-c2012-5.6)
Rule-5.9 - Advisory: internal linkage unique function name (misra-c2012-5.9)
Justification: typedefs name are only defined once (other arm_chip_xxx files are not included at the same time).
Attention
On SAM families you should configure a timer to count for ms. A TIM peripheral shall be configured in ATMEL START (with a period of 1ms). Using driver examples from ATMEL START generated code, you can add this code to your projects.
static struct timer_task TIMER_0_task1;
static volatile uint32_t uwTick = 0;
uint32_t HAL_GetTick(void) { // Declare HALTicks() at project level if you're using a different getter function name
return uwTick; }
static void TIMER_0_task1_cb(const struct timer_task *const timer_task) {
uwTick++; }
void TIMER_0_start(void) // Adapt function if TIM configured is not TIMER_0
{
TIMER_0_task1.interval = 1; // Adjust interval if TIM period is faster than 1ms (or define appropriate HAL_MS_TICKS_FACTOR)
TIMER_0_task1.cb = TIMER_0_task1_cb;
TIMER_0_task1.mode = TIMER_TASK_REPEAT;
timer_add_task(&TIMER_0, &TIMER_0_task1);
timer_start(&TIMER_0);
}

Please note TIMER_0_start() shall be called at init.

Macro Definition Documentation

◆ ARM_CMSIS_INC

#define ARM_CMSIS_INC   SAM_HEADER(SAM_FAMILY)

Alias for SAM CMSIS include.

◆ ARM_HAL_CFG

#define ARM_HAL_CFG   SAM_CONF_HEADER(SAM_FAMILY)

Alias for SAM HAL config include.

◆ HAL_MAX_TICKS

#define HAL_MAX_TICKS   ((uint32_t) -1)

HAL max Ticks value.

Note
Define HAL_MAX_TICKS with custom max value in project if tick max value is not using 32b variable full scale

◆ HAL_MS_TICKS_FACTOR

#define HAL_MS_TICKS_FACTOR   1U

HAL milliseconds multiplier (depending tick counter frequency)

Note
Define HAL_MS_TICKS_FACTOR with custom multiplier in project if tick period is not 1ms

◆ SAM_CONF_HEADER

#define SAM_CONF_HEADER ( f)
Value:
<sam.h>

<sam.h> name following sam family f

◆ SAM_HEADER

#define SAM_HEADER ( f)
Value:
XCAT(<hri_, f).h>
#define XCAT(a, b)
Preprocessor Name catenation of a and b (nesting possibility)
Definition arm_preprocess.h:46

concatenate <hri_(f).h> name following sam family f

Enumeration Type Documentation

◆ eResetSource

Source of last reset.

Enumerator
RST_POR 

Power On Reset.

RST_BODCORE 

Brown Out Reset.

RST_BODVDD 
RST_EXT 

Pin Reset (External Reset)

RST_WDT 

Watchdog Reset.

RST_SYST 

Software Reset.

RST_UNKNOWN 

Unknown Reset Source.