SRD Standelone programmation box: pit.c 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
Functions | Variables
pit.c File Reference

Source file for pit driver. More...

`#include "pit.h"`
Include dependency graph for pit.c:

Go to the source code of this file.

## Functions

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

## Variables

void(* | PitISRCallBack [2])(void) = {HardFault_Handler,HardFault_Handler}
| Pointer call back for PIT ISR interrupt. More...

## Detailed Description

Source file for pit driver.

Author
  Thibaut LALUQUE 3D-Ouest

Date
  26/09/2014

Version
  1.0

supported device : MKL16Z256VLH4

All Right Reserved.

Definition in file pit.c.

## Function Documentation

void HardFault_Handler | ( | void |  | ) |

External reference use as default pointer for ISR call back function

void PIT_IRQHandler | ( | void |  | ) |

PIT ISR handler.

Definition at line 86 of file pit.c.

References PIT_MODULE0, PIT_MODULE1, PitClearInterrupt, and PitISRCallBack.

86 {
87 if((PIT->CHANNEL[0].TCTRL == 0x03) && PIT->CHANNEL[0].TFLG) {
88 (*PitISRCallBack[0])();
89 PitClearInterrupt(PIT_MODULE0);
90 }
91
92 if((PIT->CHANNEL[1].TCTRL == 0x03) && PIT->CHANNEL[1].TFLG) {
93 (*PitISRCallBack[1])();
94 PitClearInterrupt(PIT_MODULE1);
95 }
96 }
PitClearInterrupt
#define PitClearInterrupt(moduleId)
Clear interrupt flag f the specified PIT module.
Definition: pit.h:113
PitISRCallBack
void(* PitISRCallBack[2])(void)
Pointer call back for PIT ISR interrupt.
Definition: pit.c:62
PIT_MODULE0
Definition: pit.h:63
PIT_MODULE1
Definition: pit.h:64

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:

## Variable Documentation

PitISRCallBack[2] = {HardFault_Handler,HardFault_Handler}

Pointer call back for PIT ISR interrupt.

Definition at line 62 of file pit.c.

Referenced by PIT_IRQHandler(), and PitInit().