📄 main.c
字号:
/****************************************************************************
DESCRIPTION
FILE
main.c
*/
/****************************************************************************
Header files
*/
#include <connection.h>
#include <print.h>
#include <string.h>
#include <panic.h>
#include "main.h"
#include "state.h"
#include "handle_system.h"
#include "handle_connection.h"
#include "handle_pbap.h"
/* This is the task data associated with the app. */
applicationTaskData gTheApp;
/* Inititalise the System */
static void main_init(void);
/* Main application message handler */
static void main_message_handler(Task pTask, MessageId pId, Message pMessage);
/****************************************************************************
MessageHandler
*/
static void main_message_handler(Task pTask, MessageId pId, Message pMessage)
{
applicationTaskData *lState = (applicationTaskData*)pTask;
PRINT(("AppState=%u, MsgId=0x%X - ",(uint16)lState->appState, (uint16)pId));
if ((pId >= CL_INIT_CFM) && (pId <= CL_MESSAGE_TOP))
{ /* Route Connection library messages */
handleConnectionMessages(lState, pId, pMessage);
}
else if ((pId >= PBAPC_INIT_CFM) && (pId <= PBAPC_MESSAGE_TOP))
{ /* Route Connection library messages */
handlePbapMessages(lState, pId, pMessage);
}
else if ((pId >= MESSAGE_BLUESTACK_LC_PRIM) && (pId <= MESSAGE_USB_ENUMERATED))
{ /* Route System messages */
handleSystemMessages(lState, pId, pMessage);
}
else
{ /* Unknown message */
PRINT(("Unknown Message\n"));
}
}
/****************************************************************************
Inititalise the System
*/
static void main_init(void)
{
/* Ensure everything in the task structure is initialised to sensible values (o or NULL) */
memset(&gTheApp, 0, sizeof(applicationTaskData));
gTheApp.task.handler = main_message_handler;
/* Initialise the application state */
setState(&gTheApp.appState, AppStateUninitialised);
PanicNotNull(MessageSinkTask(StreamUartSink(), &gTheApp.task));
/* Initialise the connection library */
ConnectionInit(&gTheApp.task);
}
/****************************************************************************
Entry point
*/
int main(void)
{
PRINT(("Application Started\n\n"));
main_init();
/* Start the message loop. Should not return */
MessageLoop();
/* Never get here! */
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -