在线时间2 小时
UID3378305
注册时间2018-4-28
NXP金币0
该用户从未签到
新手上路

- 积分
- 17
- 最后登录
- 2018-5-4
|

楼主 |
发表于 2018-5-4 17:28:11
|
显示全部楼层
/*
* This is template for main module created by KSDK Project Generator. Enjoy!
*/
/*
* [File Name] main.c
* [Platform] MKL17Z128VFM4
* [Project] myProject
* [Version] 1.00
* [Author] liujia
* [Date] 05/02/2018
* [Language] 'C'
* [History] 1.00 - Original Release
*
*/
//-----------------------------------------------------------------------
// Standard C/C++ Includes
//-----------------------------------------------------------------------
#include <stdio.h>
//-----------------------------------------------------------------------
// KSDK Includes
//-----------------------------------------------------------------------
#include "main.h"
#include "board.h"
#include "gpio_pins.h"
#include "fsl_debug_console.h"
#include "fsl_clock_manager.h"
#include "fsl_lpuart_driver.h"
//-----------------------------------------------------------------------
// Application Includes
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// Function Prototypes
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// Constants
//-----------------------------------------------------------------------
const uint8_t buffStart[] = "\r\n++++++++++++++++ LPUART Send/Receive Blocking Example +++++++++++++++++\r\n";
const uint8_t bufferData1[] = "\r\nType characters from keyboard, the board will receive and then echo them to terminal screen\r\n";
//-----------------------------------------------------------------------
// Typedefs
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// Global Variables
//-----------------------------------------------------------------------
volatile bool isButtonPress = false;
//-----------------------------------------------------------------------
// Macros
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// Main Function
//-----------------------------------------------------------------------
int main(void)
{
uint8_t rxChar = 0, txChar = 0;
uint32_t byteCountBuff = 0;
// Define gpio input pin config structure SW.
gpio_input_pin_user_config_t inputPin[] = {
{
.pinName = GPIO_PINS_OUT_OF_RANGE,
}
};
// Define gpio output pin config structure LED1.
gpio_output_pin_user_config_t outputPin[] = {
{
.pinName = kGpioLED1,
.config.outputLogic = 0,
#if FSL_FEATURE_PORT_HAS_SLEW_RATE
.config.slewRate = kPortFastSlewRate,
#endif
#if FSL_FEATURE_PORT_HAS_DRIVE_STRENGTH
.config.driveStrength = kPortHighDriveStrength,
#endif
},
{
.pinName = GPIO_PINS_OUT_OF_RANGE,
}
};
// Initialize variable lpuartStatePtr of type lpuart_state_t
lpuart_state_t lpuartStatePtr;
// Fill in lpuart config data
lpuart_user_config_t lpuartConfig = {
.clockSource = BOARD_LPUART_CLOCK_SOURCE,
.bitCountPerChar = kLpuart8BitsPerChar,
.parityMode = kLpuartParityDisabled,
.stopBitCount = kLpuartOneStopBit,
.baudRate = BOARD_DEBUG_UART_BAUD
};
// Init hardware
hardware_init();
// Enable LPTIMER for timeout
OSA_Init();
// Initialize the lpuart module with instance number and config structure
LPUART_DRV_Init(BOARD_DEBUG_UART_INSTANCE, &lpuartStatePtr, &lpuartConfig);
// Inform to start blocking example
byteCountBuff = sizeof(buffStart);
LPUART_DRV_SendDataBlocking(BOARD_DEBUG_UART_INSTANCE, buffStart, byteCountBuff, 1000u);
// Inform user of what to do
byteCountBuff = sizeof(bufferData1);
LPUART_DRV_SendDataBlocking(BOARD_DEBUG_UART_INSTANCE, bufferData1, byteCountBuff, 1000u);
// // Print a note to terminal.
// PRINTF("\r\n GPIO PD Driver example\r\n");
// PRINTF("\r\n Press %s to turn on/off a LED1\r\n",BOARD_SW_NAME);
// Init LED1, Switch.
GPIO_DRV_Init(inputPin, outputPin);
// Turn LED1 on.
GPIO_DRV_ClearPinOutput(kGpioLED1);
for (;;) // Forever loop
{
// PRINTF(" %s is pressed \r\n",BOARD_SW_NAME);
OSA_TimeDelay(5000);
GPIO_DRV_TogglePinOutput(kGpioLED1);
}
}
////////////////////////////////////////////////////////////////////////////////
// EOF
////////////////////////////////////////////////////////////////////////////////
|
|