📄 platforminit.c
字号:
/************************************************************************************
* This file contains Platform specific implentations of BTA functions.
* For the Windows Simulator Platform.
*
*
* (c) Copyright 2006, Freescale Semiconductor, Inc. All rights reserved.
*
* Freescale Confidential Proprietary
*
* No part of this document must be reproduced in any form - including copied,
* transcribed, printed or by any electronic means - without specific written
* permission from Freescale.
************************************************************************************/
/************************************************************************************
* Includes
************************************************************************************/
#include "IoConfig.h"
#include "PortConfig.h"
#include "IrqControlLib.h"
#include "Mc1319xDrv.h"
#include "Crt0.h"
#include "NV_Data.h"
#include "PowerManager.h"
#include "MacPhyInit.h"
#include "FunctionLib.h" // To write ext addr - pls remove this @KDO
//#include "MacConst.h" // To get aExtendedAddress - must be possible to access
#ifdef BOOTLOADER_ENABLED
#include "embedded_bootloader.h"
#endif
extern uint8_t aExtendedAddress[8];
/*************************************************************************************
*************************************************************************************
* External platform references
*************************************************************************************
************************************************************************************/
// NOTE!!! This code is only added to get the symbols in the build. The linker will remove these symbols if not referenced.
// Hope to find a better way 21.10.03 MVC
typedef void(*ISR_func_t)(void);
extern const ISR_func_t ISR_vectors[];
extern const ISR_func_t Reset_vector[]; // The system reset vector
#ifdef BOOTLOADER_ENABLED
extern const uint8_t interface_status;
extern const uint8_t boot_loader_flag;
#endif BOOTLOADER_ENABLED
/*************************************************************************************
*************************************************************************************
* Private functions
*************************************************************************************
************************************************************************************/
/************************************************************************************
*************************************************************************************
* Public function(s)
*************************************************************************************
************************************************************************************/
/************************************************************************************
* Perform the complete GPIO port initialization
*
* Interface assumptions:
*
* Return value:
* NONE
*
* Revision history:
*
* Date Author Comments
* ------ ------ --------
* 190505 JT Created
*
************************************************************************************/
void PlatformPortInit(void)
{
// Platform ports default configuration/initialization
// Setup port A
mSETUP_PORT_A
// Setup Port B
mSETUP_PORT_B
// Setup port C
mSETUP_PORT_C
// Setup port D
mSETUP_PORT_D
// Setup port E
mSETUP_PORT_E
// Setup port F
mSETUP_PORT_F
// Setup port G
mSETUP_PORT_G
#if (gTarget_UserDefined_d == 1)
mSETUP_TRANCEIVER_PORT
mSETUP_SWICH_PORT
mSETUP_LED_PORT
mSETUP_SCIxPINS
#endif
#ifdef I_AM_A_SNIFFER
TPM1SC = 0x0c; // Use BUSCLK and prescale with factor 16 (to get 1 us)
TPM1C1SC = 0x04; // Disable interrupt, Input capture, Capture on rising edge
#endif I_AM_A_SNIFFER
}
/************************************************************************************
* Initialize platform specific stuff
* NVRAM, Bootloader, MC1319x driver etc.
*
* Interface assumptions:
*
* NOTE!!! This First section of this function code is added to ensure that the symbols
* are included in the build. The linker will remove these symbols if not referenced.
* Hope to find a better way 21.10.03 MVC
*
* Return value:
* NONE
*
* Revision history:
*
* Date Author Comments
* ------ ------ --------
* 030505 JT Created
*
************************************************************************************/
void Platform_Init(void) {
/************* Symbol include section begin *************************/
#ifndef BOOTLOADER_ENABLED
if(none_volatile_struct.nv_backkey[0] == 0)
IrqControlLib_DisableAllIrqs();
if(Reset_vector[0] == (ISR_func_t)0x0000)
IrqControlLib_DisableAllIrqs();
#endif BOOTLOADER_ENABLED
if(ISR_vectors[0] == (ISR_func_t)0x0000)
IrqControlLib_DisableAllIrqs();
if((Freescale_Copyright[0] == 0x00) || (Firmware_Database_Label[0] == 0x00) ||
(MAC_Version[0] == 0x00) || (PHY_Version[0] == 0x00) || (gpMacNvram->Freescale_Copyright[0] == 0x00) ||
(mNvramMac.MAC_Address[0] == 0x00))
{
IrqControlLib_DisableAllIrqs();
NV_Data_Init();
}
//following lines are required to place the default values into flash
//otherwise the the cw will optimize as it is not being used.
if (( gNvramZS1.Version == 0x00 ) || ( gNvramZS2.Version == 0x00 ))
{
IrqControlLib_DisableAllIrqs();
NV_Data_Init();
}
#ifdef BOOTLOADER_ENABLED
if(boot_loader_control == ((uint8_t)0x00))
IrqControlLib_DisableAllIrqs();
if(boot_loader_flag == ((uint8_t)0x00))
IrqControlLib_DisableAllIrqs();
BootLoader_Interface_Init();
#endif BOOTLOADER_ENABLED
#ifdef FLASH_LIB_ENABLED
// Add this compiler define if the flash library is included in the application
NV_Flash_Setup();
#endif FLASH_LIB_ENABLED
// Insert correct IEEE address from NV RAM
FLib_MemCpy(aExtendedAddress, (NvramStruct_t *)gpMacNvram->MAC_Address, 8);
/************* Symbol include section end ****************************/
// Init MCU specifics: GPIO ports, SPI - and reset MC1319x
PlatformPortInit(); // Initializes GPIO port settings.
MC1319xDrv_Init(); // Init SPI for MC1319x driver
MC1319xDrv_Reset(); // Reset MC1319x
// Ensure MCU clk is stable
PowerManager_WaitForPowerUp();
}
/************************************************************************************
* Initialize platform and stack.
*
* This function is the main initialization procedure, which will be called from the
* startup code of the project.
* If the code is build as a stand-alone application, this function is
* called from main() below.
*
* Interface assumptions:
*
* Return value:
* NONE
*
* Revision history:
*
* Date Author Comments
* ------ ------ --------
* 030505 JT Created
*
************************************************************************************/
void Init_802_15_4(void) {
bool_t relaxedTiming;
Platform_Init(); // Init platform
relaxedTiming = gpMacNvram->Bus_Frequency_In_MHz<12;
// Init 802.15.4 MAC/PHY stack
MacPhyInit_Initialize(relaxedTiming, gpMacNvram->Abel_HF_Calibration,
gpMacNvram->defaultPowerLevel, NULL, gpMacNvram->useDualAntenna);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -