rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
board.c
Go to the documentation of this file.
1/**
2 * @file board.c
3 * @brief Board initialization file.
4 * @author andreika <prometheus.pcb@gmail.com>
5 */
6
7/* This is a template for board specific configuration created by MCUXpresso IDE Project Wizard.*/
8
9#include <stdint.h>
10#include "board.h"
11#include "hal.h"
12
13void delay(void)
14{
15 volatile uint32_t i = 0;
16 for (i = 0; i < 800000; ++i)
17 {
18 __asm("NOP"); /* delay */
19 }
20}
21
22/* Test LED blinker (Uses PD7). Should work in any conditions! */
23void __blink(int n) {
24#if 1
25 PCC->CLKCFG[PCC_PORTD_INDEX] |= PCC_CLKCFG_CGC_MASK; // enable clock on PORT D
26 PORTD->PCR[7U] = (PORTD->PCR[7U] & ~PORT_PCR_MUX_MASK) | PORT_PCR_MUX(1/*kPORT_MuxAsGpio*/);
27 GPIOD->PSOR = 1U << 7U;
28 GPIOD->PDDR |= (1U << 7U);
29 int k;
30 for (k = 0; k < 1; k++) {
31 GPIOD->PCOR = 1U << 7U;
32 for (int i = 0; i < 2*n; i++)
33 {
34 GPIOD->PTOR = (1U << 7U);
35 delay();
36 }
37 GPIOD->PSOR = 1U << 7U;
38
39 for (int kk = 0; kk < 8; kk++) {
40 delay();
41 }
42 }
43/*
44 for (k = 0; k < 10; k++) {
45 delay();
46 }
47*/
48#endif
49}
50
51void disableWatchdog(void) {
52 WDOG->CNT = WDOG_UPDATE_KEY;
53 WDOG->TOVAL = 0xFFFF;
54 WDOG->CS = (uint32_t) ((WDOG->CS) & ~WDOG_CS_EN_MASK) | WDOG_CS_UPDATE_MASK;
55}
56
57void __early_init(void) {
58 ke1xf_init();
59}
60
61void __late_init(void) {
62 // we need static variables to be already initialized
63 // to configure the clock properly and save its state
64 ke1xf_clock_init(KINETIS_DEFAULT_CLK);
65}
66
67void boardInit(void) {
68}
void ke1xf_clock_init(kinetis_clock_type_e ct)
This function executes the configuration of clocks.
void __early_init(void)
Definition board.c:21
void delay(void)
Definition board.c:12
void boardInit(void)
Definition board.c:31
void __late_init(void)
Definition board.c:25
void ke1xf_init(void)
KE1xF initialization.
Definition hal_lld.c:112
void disableWatchdog(void)
Definition board.c:51
void __blink(int n)
Definition board.c:23