最近在做一个医疗产品的电路板,有一个无线模块和一个Avr单片机,过程是先烧录无线模块,再烧录单片机,单片机先烧熔丝,然后再烧flash,有时候搜不到信号(WiFi),重新烧写一下单片机就好了,我想知道,单片机到底控制了无线模块的什么呢?因为程序是别人写的,所以不太明白。
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
最近在做一个医疗产品的电路板,有一个无线模块和一个Avr单片机,过程是先烧录无线模块,再烧录单片机,单片机先烧熔丝,然后再烧flash,有时候搜不到信号(WiFi),重新烧写一下单片机就好了,我想知道,单片机到底控制了无线模块的什么呢?因为程序是别人写的,所以不太明白。
建议联系你的那个模块的厂家吧,这个不好推测,看起来应该操作的是AP mode。
//****************************************************************************
//
//! \brief start simplelink, wait for the sta to connect to the device and
//! run the ping test for that sta
//!
//! \param pvparameters is the pointer to the list of parameters that can be
//! passed to the task while creating it
//!
//! \return None
//
//****************************************************************************
void WlanAPMode( void *pvParameters )
{
int iTestResult = 0;
unsigned char ucDHCP;
long lRetVal = -1;
InitializeAppVariables();
//
// Following function configure the device to default state by cleaning
// the persistent settings stored in NVMEM (viz. connection profiles &
// policies, power policy etc)
//
// Applications may choose to skip this step if the developer is sure
// that the device is in its default state at start of applicaton
//
// Note that all profiles and persistent settings that were done on the
// device will be lost
//
lRetVal = ConfigureSimpleLinkToDefaultState();
if(lRetVal < 0)
{
if (DEVICE_NOT_IN_STATION_MODE == lRetVal)
UART_PRINT("Failed to configure the device in its default state \n\r");
LOOP_FOREVER();
}
UART_PRINT("Device is configured in default state \n\r");
//
// Asumption is that the device is configured in station mode already
// and it is in its default state
//
lRetVal = sl_Start(NULL,NULL,NULL);
if (lRetVal < 0)
{
UART_PRINT("Failed to start the device \n\r");
LOOP_FOREVER();
}
UART_PRINT("Device started as STATION \n\r");
//
// Configure the networking mode and ssid name(for AP mode)
//
if(lRetVal != ROLE_AP)
{
if(ConfigureMode(lRetVal) != ROLE_AP)
{
UART_PRINT("Unable to set AP mode, exiting Application...\n\r");
sl_Stop(SL_STOP_TIMEOUT);
LOOP_FOREVER();
}
}
while(!IS_IP_ACQUIRED(g_ulStatus))
{
//looping till ip is acquired
}
unsigned char len = sizeof(SlNetCfgIpV4Args_t);
SlNetCfgIpV4Args_t ipV4 = {0};
// get network configuration
lRetVal = sl_NetCfgGet(SL_IPV4_AP_P2P_GO_GET_INFO,&ucDHCP,&len,
(unsigned char *)&ipV4);
if (lRetVal < 0)
{
UART_PRINT("Failed to get network configuration \n\r");
LOOP_FOREVER();
}
UART_PRINT("Connect a client to Device\n\r");
while(!IS_IP_LEASED(g_ulStatus))
{
//wating for the client to connect
}
UART_PRINT("Client is connected to Device\n\r");
iTestResult = PingTest(g_ulStaIp);
if(iTestResult < 0)
{
UART_PRINT("Ping to client failed \n\r");
}
UNUSED(ucDHCP);
UNUSED(iTestResult);
// revert to STA mode
lRetVal = sl_WlanSetMode(ROLE_STA);
if(lRetVal < 0)
{
ERR_PRINT(lRetVal);
LOOP_FOREVER();
}
// Switch off Network processor
lRetVal = sl_Stop(SL_STOP_TIMEOUT);
UART_PRINT("WLAN AP example executed successfully");
while(1);
}