Statistics
| Branch: | Tag: | Revision:

mongoose / examples / NXP_K64 / board.h @ eaef5bd1

History | View | Annotate | Download (6.44 KB)

1
/* clang-format off */
2
/*
3
* Copyright (c) 2015, Freescale Semiconductor, Inc.
4
* All rights reserved.
5
*
6
* Redistribution and use in source and binary forms, with or without modification,
7
* are permitted provided that the following conditions are met:
8
*
9
* o Redistributions of source code must retain the above copyright notice, this list
10
*   of conditions and the following disclaimer.
11
*
12
* o Redistributions in binary form must reproduce the above copyright notice, this
13
*   list of conditions and the following disclaimer in the documentation and/or
14
*   other materials provided with the distribution.
15
*
16
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
17
*   contributors may be used to endorse or promote products derived from this
18
*   software without specific prior written permission.
19
*
20
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
24
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
27
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
*/
31

    
32
#ifndef _BOARD_H_
33
#define _BOARD_H_
34

    
35
#include "clock_config.h"
36
#include "fsl_gpio.h"
37

    
38
/*******************************************************************************
39
 * Definitions
40
 ******************************************************************************/
41

    
42
/* The board name */
43
#define BOARD_NAME "FRDM-K64F"
44

    
45
/* The UART to use for debug messages. */
46
#define BOARD_DEBUG_UART_TYPE DEBUG_CONSOLE_DEVICE_TYPE_UART
47
#define BOARD_DEBUG_UART_BASEADDR (uint32_t) UART0
48
#define BOARD_DEBUG_UART_CLKSRC SYS_CLK
49
#define BOARD_DEBUG_UART_CLK_FREQ CLOCK_GetCoreSysClkFreq()
50
#define BOARD_UART_IRQ UART0_RX_TX_IRQn
51
#define BOARD_UART_IRQ_HANDLER UART0_RX_TX_IRQHandler
52

    
53
#ifndef BOARD_DEBUG_UART_BAUDRATE
54
#define BOARD_DEBUG_UART_BAUDRATE 115200
55
#endif /* BOARD_DEBUG_UART_BAUDRATE */
56

    
57
/* Define the port interrupt number for the board switches */
58
#define BOARD_SW2_GPIO GPIOC
59
#define BOARD_SW2_PORT PORTC
60
#define BOARD_SW2_GPIO_PIN 6U
61
#define BOARD_SW2_IRQ PORTC_IRQn
62
#define BOARD_SW2_IRQ_HANDLER PORTC_IRQHandler
63
#define BOARD_SW2_NAME "SW2"
64

    
65
#define BOARD_SW3_GPIO GPIOA
66
#define BOARD_SW3_PORT PORTA
67
#define BOARD_SW3_GPIO_PIN 4U
68
#define BOARD_SW3_IRQ PORTA_IRQn
69
#define BOARD_SW3_IRQ_HANDLER PORTA_IRQHandler
70
#define BOARD_SW3_NAME "SW3"
71

    
72
/* Board led color mapping */
73
#define LOGIC_LED_ON 0U
74
#define LOGIC_LED_OFF 1U
75
#define BOARD_LED_RED_GPIO GPIOB
76
#define BOARD_LED_RED_GPIO_PORT PORTB
77
#define BOARD_LED_RED_GPIO_PIN 22U
78
#define BOARD_LED_GREEN_GPIO GPIOE
79
#define BOARD_LED_GREEN_GPIO_PORT PORTE
80
#define BOARD_LED_GREEN_GPIO_PIN 26U
81
#define BOARD_LED_BLUE_GPIO GPIOB
82
#define BOARD_LED_BLUE_GPIO_PORT PORTB
83
#define BOARD_LED_BLUE_GPIO_PIN 21U
84

    
85
#define LED_RED_INIT(output)                                 \
86
    GPIO_PinInit(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PIN, \
87
                 &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}) /*!< Enable target LED_RED */
88
#define LED_RED_ON() \
89
    GPIO_ClearPinsOutput(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn on target LED_RED */
90
#define LED_RED_OFF() \
91
    GPIO_SetPinsOutput(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn off target LED_RED */
92
#define LED_RED_TOGGLE() \
93
    GPIO_TogglePinsOutput(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Toggle on target LED_RED */
94

    
95
#define LED_GREEN_INIT(output)                                   \
96
    GPIO_PinInit(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PIN, \
97
                 &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}) /*!< Enable target LED_GREEN */
98
#define LED_GREEN_ON() \
99
    GPIO_ClearPinsOutput(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn on target LED_GREEN */
100
#define LED_GREEN_OFF() \
101
    GPIO_SetPinsOutput(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn off target LED_GREEN */
102
#define LED_GREEN_TOGGLE() \
103
    GPIO_TogglePinsOutput(BOARD_LED_GREEN_GPIO, 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Toggle on target LED_GREEN */
104

    
105
#define LED_BLUE_INIT(output)                                  \
106
    GPIO_PinInit(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PIN, \
107
                 &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}) /*!< Enable target LED_BLUE */
108
#define LED_BLUE_ON() \
109
    GPIO_ClearPinsOutput(BOARD_LED_BLUE_GPIO, 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn on target LED_BLUE */
110
#define LED_BLUE_OFF() \
111
    GPIO_SetPinsOutput(BOARD_LED_BLUE_GPIO, 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn off target LED_BLUE */
112
#define LED_BLUE_TOGGLE() \
113
    GPIO_TogglePinsOutput(BOARD_LED_BLUE_GPIO, 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Toggle on target LED_BLUE */
114

    
115
/* The SDHC instance/channel used for board */
116
#define BOARD_SDHC_CD_GPIO_IRQ_HANDLER PORTB_IRQHandler
117

    
118
/* SDHC base address, clock and card detection pin */
119
#define BOARD_SDHC_BASEADDR SDHC
120
#define BOARD_SDHC_CLKSRC kCLOCK_CoreSysClk
121
#define BOARD_SDHC_IRQ SDHC_IRQn
122
#define BOARD_SDHC_CD_GPIO_BASE GPIOE
123
#define BOARD_SDHC_CD_GPIO_PIN 6U
124
#define BOARD_SDHC_CD_PORT_BASE PORTE
125
#define BOARD_SDHC_CD_PORT_IRQ PORTE_IRQn
126
#define BOARD_SDHC_CD_PORT_IRQ_HANDLER PORTE_IRQHandler
127
#define BOARD_SDHC_CD_LOGIC_RISING
128

    
129
#define BOARD_ACCEL_I2C_BASEADDR I2C0
130

    
131
/* @brief FreeRTOS tickless timer configuration. */
132
#define vPortLptmrIsr LPTMR0_IRQHandler /*!< Timer IRQ handler. */
133
#define TICKLESS_LPTMR_BASE_PTR LPTMR0  /*!< Tickless timer base address. */
134
#define TICKLESS_LPTMR_IRQn LPTMR0_IRQn /*!< Tickless timer IRQ number. */
135

    
136
/* @brief pit IRQ configuration for lwip demo */
137
#define LWIP_TIME_ISR PIT0_IRQHandler
138
#define LWIP_PIT_IRQ_ID PIT0_IRQn
139

    
140
#if defined(__cplusplus)
141
extern "C" {
142
#endif /* __cplusplus */
143

    
144
/*******************************************************************************
145
 * API
146
 ******************************************************************************/
147
void BOARD_InitDebugConsole(void);
148

    
149
#if defined(__cplusplus)
150
}
151
#endif /* __cplusplus */
152

    
153
#endif /* _BOARD_H_ */