SRD Standelone programmation box: pit.h File Reference

| SRD Standelone programmation box 2.0 (16/11/15 10:00:00) Documentation of the SRD standelone programmation box

- Main Page
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Enumerations Enumerator Macros Pages
Macros | Enumerations | Functions
pit.h File Reference

Headerfile for pit peripheral driver. More...

`#include "dsp.h"`
Include dependency graph for pit.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Macros

#define | PIT_FREEZE_IN_DEBUG
| Comment this to continue PIT operation when device is in halt debug mode. More...
#define | PIT_INTERRUPT_PRIORITY (8)
| PIT priority interrupt. More...
#define | PitClearInterrupt(moduleId) (PIT->CHANNEL[moduleId].TFLG = 1)
| Clear interrupt flag f the specified PIT module. More...
#define | PitDisableInterrupt(moduleId) (PIT->CHANNEL[moduleId].TCTRL &= 0xFD)
| Enable / Disable interrupt of the PIT module. More...
#define | PitEnableInterrupt(moduleId) (PIT->CHANNEL[moduleId].TCTRL |= 0x02)
| Enable / Disable interrupt of the PIT module. More...
#define | PitEnable(moduleId) (PIT->CHANNEL[moduleId].TCTRL |= 0x01)
| Enable / Disable the PIT module. More...
#define | PitDisable(moduleId) (PIT->CHANNEL[moduleId].TCTRL &= 0xFE)
| Enable / Disable the PIT module. More...

## Enumerations

enum | tPitModuleId { PIT_MODULE0 = 0, PIT_MODULE1 = 1 }
| PIT module ID. More...

## Functions

void | PitInit (tPitModuleId moduleId, unsigned long freq, void(*ISRCallBack)(void))
| Initialize a PIT module. More...

## Detailed Description

Headerfile for pit peripheral driver.

Author
  Thibaut LALUQUE 3D-Ouest

Date
  26/09/2014

Version
  1.0

supported device : MKL16Z256VLH4

All Right Reserved.

Definition in file pit.h.

## Macro Definition Documentation

#define PIT_FREEZE_IN_DEBUG

Comment this to continue PIT operation when device is in halt debug mode.

Definition at line 36 of file pit.h.

#define PIT_INTERRUPT_PRIORITY (8)

PIT priority interrupt.

Set betwenn 0(highest priority) and 3(lowest priority).

Definition at line 45 of file pit.h.

Referenced by PitInit().

#define PitClearInterrupt | ( |  | moduleId | ) | (PIT->CHANNEL[moduleId].TFLG = 1)

Clear interrupt flag f the specified PIT module.

Parameters

  [in] | moduleId | (tPitModuleId) : ID of the PIT module.

Definition at line 113 of file pit.h.

Referenced by PIT_IRQHandler(), and PitInit().

#define PitDisable | ( |  | moduleId | ) | (PIT->CHANNEL[moduleId].TCTRL &= 0xFE)

Enable / Disable the PIT module.

Parameters

  [in] | moduleId | (tPitModuleId) : ID of the PIT module.

When enable the PIT module start to count down and raise interrupt. interrupt continue to occurs at the frequency of the PIT module unless the PIT module will be disable

Definition at line 125 of file pit.h.

#define PitDisableInterrupt | ( |  | moduleId | ) | (PIT->CHANNEL[moduleId].TCTRL &= 0xFD)

Enable / Disable interrupt of the PIT module.

Parameters

  [in] | moduleId | (tPitModuleId) : ID of the PIT module.

Definition at line 102 of file pit.h.

Referenced by PitInit().

#define PitEnable | ( |  | moduleId | ) | (PIT->CHANNEL[moduleId].TCTRL |= 0x01)

Enable / Disable the PIT module.

Parameters

  [in] | moduleId | (tPitModuleId) : ID of the PIT module.

When enable the PIT module start to count down and raise interrupt. interrupt continue to occurs at the frequency of the PIT module unless the PIT module will be disable

Definition at line 124 of file pit.h.

#define PitEnableInterrupt | ( |  | moduleId | ) | (PIT->CHANNEL[moduleId].TCTRL |= 0x02)

Enable / Disable interrupt of the PIT module.

Parameters

  [in] | moduleId | (tPitModuleId) : ID of the PIT module.

Definition at line 103 of file pit.h.

Referenced by TickInit().

## Enumeration Type Documentation

enum tPitModuleId

PIT module ID.

Define the PIT module ID available for this device.

Enumerator
PIT_MODULE0 |
PIT_MODULE1 |

Definition at line 62 of file pit.h.

62 {
63 PIT_MODULE0 = 0,
64 PIT_MODULE1 = 1
65 }tPitModuleId;
PIT_MODULE0
Definition: pit.h:63
PIT_MODULE1
Definition: pit.h:64
tPitModuleId
tPitModuleId
PIT module ID.
Definition: pit.h:62

## Function Documentation

void PitInit | ( | tPitModuleId | moduleId,
|  | unsigned long | freq,
|  | void(*)(void) | ISRCallBack
| ) |  |

Initialize a PIT module.

Parameters

  [in] | moduleId | (tPitModuleId) : ID of the module to initialize.
  [in] | freq | (unsigned long) : PIT interrupt period (in Hz).
  [in] | ISRCallBack | (void (*ISRCallBack)(void)) : pointer on the Call Back function use to deal this interrupt.

Definition at line 105 of file pit.c.

References IPR_NVIC_PIT_MASK, IPR_NVIC_PIT_REG, IPR_NVIC_PIT_SHIFT, NVIC_PIT_MASK, NVIC_PIT_REG, PIT_CLOCK_SOURCE, PIT_INTERRUPT_PRIORITY, PitClearInterrupt, PitDisableInterrupt, and PitISRCallBack.

Referenced by TickInit().

105 {
106
107 /*-- Turn on clock on pit module --*/
108 SIM->SCGC6 |= 1<<23;
109
110 /*-- Enable module --*/
111 #ifdef PIT_FREEZE_IN_DEBUG
112 PIT->MCR = 0x0001;
113 #else
114 PIT->MCR = 0x0000;
115 #endif
116
117 /*-- make sure to disable module and update period --*/
118 PIT->CHANNEL[moduleId].TCTRL = 0x00;
119 PIT->CHANNEL[moduleId].LDVAL = (PIT_CLOCK_SOURCE / freq) - 1;
120
121 /*-- Set interrupt configuration --*/
122 PitDisableInterrupt(moduleId);
123 PitClearInterrupt(moduleId);
124 PitISRCallBack[moduleId] = ISRCallBack;
125 NVIC->IP[IPR_NVIC_PIT_REG] = (NVIC->IP[IPR_NVIC_PIT_REG] & ~IPR_NVIC_PIT_MASK) | ((PIT_INTERRUPT_PRIORITY & 0x03) << IPR_NVIC_PIT_SHIFT);
126 NVIC->ISER[NVIC_PIT_REG] |= NVIC_PIT_MASK;
127 }
PitClearInterrupt
#define PitClearInterrupt(moduleId)
Clear interrupt flag f the specified PIT module.
Definition: pit.h:113
PIT_INTERRUPT_PRIORITY
#define PIT_INTERRUPT_PRIORITY
PIT priority interrupt.
Definition: pit.h:45
PIT_CLOCK_SOURCE
#define PIT_CLOCK_SOURCE
Define clock source for peripehrals.
Definition: DSP_mkl16z256vlh4.h:301
PitISRCallBack
void(* PitISRCallBack[2])(void)
Pointer call back for PIT ISR interrupt.
Definition: pit.c:62
IPR_NVIC_PIT_MASK
#define IPR_NVIC_PIT_MASK
Define NVIC PIT register used by specific peripherals.
Definition: DSP_mkl16z256vlh4.h:118
IPR_NVIC_PIT_REG
#define IPR_NVIC_PIT_REG
Define NVIC PIT register used by specific peripherals.
Definition: DSP_mkl16z256vlh4.h:94
IPR_NVIC_PIT_SHIFT
#define IPR_NVIC_PIT_SHIFT
Define NVIC PIT register used by specific peripherals.
Definition: DSP_mkl16z256vlh4.h:117
NVIC_PIT_MASK
#define NVIC_PIT_MASK
Define NVIC mask and shift values used by specific peripherals.
Definition: DSP_mkl16z256vlh4.h:65
NVIC_PIT_REG
#define NVIC_PIT_REG
Define NVIC register used by specific peripherals.
Definition: DSP_mkl16z256vlh4.h:41
PitDisableInterrupt
#define PitDisableInterrupt(moduleId)
Enable / Disable interrupt of the PIT module.
Definition: pit.h:102

Here is the caller graph for this function: