Sample SPI drivers for a number of the Adesto Technologies flash devices.
user_config.c
Go to the documentation of this file.
1 /*
2  * The Clear BSD License
3  * Copyright (c) 2018 Adesto Technologies Corporation, Inc
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without modification,
7  * are permitted (subject to the limitations in the disclaimer below) provided
8  * that the following conditions are met:
9  *
10  * o Redistributions of source code must retain the above copyright notice, this list
11  * of conditions and the following disclaimer.
12  *
13  * o Redistributions in binary form must reproduce the above copyright notice, this
14  * list of conditions and the following disclaimer in the documentation and/or
15  * other materials provided with the distribution.
16  *
17  * o Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived from this
19  * software without specific prior written permission.
20  *
21  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
26  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
42 #include "user_config.h"
43 
44 void USER_CONFIG_PinInit(uint32_t port, uint32_t pin, enum directionIO direction)
45 {
46  if(direction == OUTPUT)
47  {
48  // Set the direction of a GPIO pin as an output.
49  // Create the NXP GPIO configuration type and set it as an output; <- NXP
50  // gpio_pin_config_t spi_config_out = {kGPIO_DigitalOutput, 0U}; <- NXP
51  // Use the config structure and GPIO driver function call to set the pin as an input <- NXP
52  // GPIO_PinInit((GPIO_Type *)port, pin, &spi_config_out); <- NXP
53  }
54  else if(direction == INPUT)
55  {
56  // Set the direction of a GPIO pin as an input.
57  // Create the NXP GPIO configuration type and set it as an input. <- NXP
58  // gpio_pin_config_t spi_config_in = {kGPIO_DigitalInput, 0U}; <- NXP
59  // Use the config structure and GPIO driver function call to set the pin as an input <- NXP
60  // GPIO_PinInit((GPIO_Type *)port, pin, &spi_config_in); <- NXP
61  }
62 }
63 
64 void USER_CONFIG_PinClear(uint32_t port, uint32_t pin)
65 {
66  // Clear the output voltage on a given pin to LOW.
67  // GPIO_PinWrite((GPIO_Type *)port, pin, 0); <- NXP
68 }
69 
70 void USER_CONFIG_PinSet(uint32_t port, uint32_t pin)
71 {
72  // Set the output voltage on a given pin to HIGH.
73  // GPIO_PinWrite((GPIO_Type *)port, pin, 1); <- NXP
74 }
75 
76 uint8_t USER_CONFIG_PinRead(uint32_t port, uint32_t pin)
77 {
78  // Read the voltage on a given pin and return the value (0 is LOW, 1 is HIGH)
79  // return (uint8_t) GPIO_PinRead((GPIO_Type *)port, pin); <- NXP
80 }
81 
83 {
84  /* Init board hardware. */
85  // Set pinmuxes and clock
86  // BOARD_InitBootPins(); <- NXP
87  // BOARD_InitBootClocks(); <- NXP
88  // BOARD_InitBootPeripherals(); <- NXP
89  /* Init FSL debug console. */
90  // BOARD_InitDebugConsole(); <- NXP
91 }
Project declarations exist here.
void USER_CONFIG_BoardInit()
Configures the board for program usage. Initializes the requisite ports/pins for use as GPIOs...
Definition: user_config.c:82
void USER_CONFIG_PinInit(uint32_t port, uint32_t pin, enum directionIO direction)
Initializes a given pin as either an input or output. When porting, this function must be redefined...
Definition: user_config.c:44
directionIO
Enumeration used when initializing pins as inputs or outputs. OUTPUT = 0, INPUT = 1...
Definition: user_config.h:205
void USER_CONFIG_PinClear(uint32_t port, uint32_t pin)
Clears a given pin on a port to LOW.
Definition: user_config.c:64
uint8_t USER_CONFIG_PinRead(uint32_t port, uint32_t pin)
Reads the voltage on a given pin.
Definition: user_config.c:76
void USER_CONFIG_PinSet(uint32_t port, uint32_t pin)
Sets a given pin on a port to HIGH.
Definition: user_config.c:70