Sync inav to Gitea
Make sure docs are updated / settings_md (push) Canceled after 0s
Build firmware / test (push) Canceled after 0s
Build firmware / build-SITL-Windows (push) Canceled after 0s
Build firmware / build-SITL-Mac (push) Canceled after 0s
Build firmware / build-SITL-Linux (push) Canceled after 0s
Build firmware / build-SITL-Linux-arm64 (push) Canceled after 0s
Build firmware / upload-artifacts (push) Canceled after 0s
Build firmware / build-single-target (push) Canceled after 0s
Build firmware / build (9) (push) Canceled after 0s
Build firmware / build (8) (push) Canceled after 0s
Build firmware / build (7) (push) Canceled after 0s
Build firmware / build (6) (push) Canceled after 0s
Build firmware / build (5) (push) Canceled after 0s
Build firmware / build (4) (push) Canceled after 0s
Build firmware / build (3) (push) Canceled after 0s
Build firmware / build (2) (push) Canceled after 0s
Build firmware / build (14) (push) Canceled after 0s
Build firmware / build (13) (push) Canceled after 0s
Build firmware / build (12) (push) Canceled after 0s
Build firmware / build (11) (push) Canceled after 0s
Build firmware / build (10) (push) Canceled after 0s
Build firmware / build (1) (push) Canceled after 0s
Build firmware / build (0) (push) Canceled after 0s
Build firmware / detect (push) Canceled after 0s
Build pre-release / build (push) Canceled after 0s
Build pre-release / Release (push) Canceled after 0s
@@ -0,0 +1,73 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team via this [link](https://www.st.com/content/st_com/en/contact-us.html).
|
||||
All complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 1.4,
|
||||
available [here](https://www.contributor-covenant.org/version/1/4/code-of-conduct.html).
|
||||
|
||||
For answers to common questions about this code of conduct, see the [FAQ section](https://www.contributor-covenant.org/faq).
|
||||
@@ -0,0 +1,24 @@
|
||||
# Contributing guide
|
||||
|
||||
This guide serves as a checklist before contributing to this repository. It mainly focuses on the steps to follow to submit an issue or a pull-request.
|
||||
|
||||
## 1. Issues
|
||||
|
||||
### 1.1 Before opening an issue
|
||||
|
||||
Please check the following points before posting an issue:
|
||||
* Make sure you are using the latest commit (major releases are tagged, but corrections are available as new commits).
|
||||
* Make sure your issue is a question/feedback/suggestions **related to** the software provided in this repository. Otherwise, please refer to section [3](CONTRIBUTING.md#3-support-requests-and-questions) below.
|
||||
* Make sure your issue is not already reported/fixed on GitHub or discussed on a previous issue. Do not forget to browse into the **closed** issues.
|
||||
|
||||
### 1.2 Posting the issue
|
||||
|
||||
When you have checked the previous points, create a new report from the **Issues** tab of this repository. A template is available [here](../../issues/new/choose) to help you report the issue you are facing or the enhancement you would like to propose.
|
||||
|
||||
## 2. Pull Requests
|
||||
|
||||
Pull-requests are **not** accepted on this repository. Please use **issues** to report any bug or request.
|
||||
|
||||
## 3. Support requests and questions
|
||||
|
||||
For support requests or any other question related to the product, the tools, the environment, you can submit a post to the **ST Community** on the appropriate topic [page](https://community.st.com/s/topiccatalog).
|
||||
@@ -0,0 +1,268 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file checksum_utils.c
|
||||
* @author MCD Application Team
|
||||
* @brief Host driver checksum utils of MXCHIP Wi-Fi component.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/*cstat -MISRAC2012-* */
|
||||
#include "stdio.h"
|
||||
/*cstat +MISRAC2012-* */
|
||||
|
||||
#include "CheckSumUtils.h"
|
||||
|
||||
#ifdef CHECKSUM_DEBUG
|
||||
#define DEBUG_LOG printf
|
||||
#else
|
||||
#define DEBUG_LOG
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef USE_STM32L_CRC
|
||||
|
||||
/* User-defined polynomial */
|
||||
#define CRC_POLYNOMIAL_16B 0x1021 /* X^16 + X^12 + X^5 + 1, CRC-CCITT generating polynomial */
|
||||
|
||||
/* User-defined CRC init value */
|
||||
/* As the CRC is 16-bit long, the init value is 16-bit long as well */
|
||||
#define CRC_INIT_VALUE 0x0000//0x5ABE
|
||||
|
||||
#endif /* USE_STM32L_CRC */
|
||||
|
||||
|
||||
static uint8_t UpdateCRC8(uint8_t crcIn, uint8_t byte)
|
||||
{
|
||||
uint8_t crc = crcIn;
|
||||
uint8_t i;
|
||||
|
||||
crc ^= byte;
|
||||
|
||||
for (i = 0; i < (uint8_t)8; i++)
|
||||
{
|
||||
if ((crc & (uint8_t)0x01) > 0u)
|
||||
{
|
||||
crc = (crc >> 1) ^ (uint8_t)0x8C;
|
||||
}
|
||||
else
|
||||
{
|
||||
crc >>= 1;
|
||||
}
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
|
||||
void CRC8_Init(CRC8_Context *inContext)
|
||||
{
|
||||
inContext->crc = 0;
|
||||
}
|
||||
|
||||
|
||||
void CRC8_Update(CRC8_Context *inContext, const uint8_t *inSrc, size_t inLen)
|
||||
{
|
||||
const uint8_t *src = (const uint8_t *) inSrc;
|
||||
const uint8_t *srcEnd = &(src[inLen]);
|
||||
while (src < srcEnd)
|
||||
{
|
||||
inContext->crc = UpdateCRC8(inContext->crc, *src);
|
||||
src++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CRC8_Final(CRC8_Context *inContext, uint8_t *outResult)
|
||||
{
|
||||
*outResult = inContext->crc & 0xffu;
|
||||
}
|
||||
|
||||
|
||||
/*************************************CRC16******************************************/
|
||||
|
||||
#ifdef USE_STM32L_CRC
|
||||
/**
|
||||
* @brief CRC16 init function
|
||||
*/
|
||||
int8_t HW_CRC16_Init(CRC_HandleTypeDef *CrcHandle)
|
||||
{
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* CRC peripheral initialization */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
|
||||
if (NULL == CrcHandle)
|
||||
{
|
||||
DEBUG_LOG("*** CRC16_Init: CrcHandle null error !\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
CrcHandle->Instance = CRC;
|
||||
|
||||
/* The default polynomial is not used. The one to be used must be defined
|
||||
in CrcHandle.Init.GeneratingPolynomial */
|
||||
CrcHandle->Init.DefaultPolynomialUse = DEFAULT_POLYNOMIAL_DISABLE;
|
||||
|
||||
/* Set the value of the generating polynomial.
|
||||
The one used in that example is the 16-bit long CRC generating
|
||||
polynomial X^16 + X^12 + X^5 + 1 */
|
||||
CrcHandle->Init.GeneratingPolynomial = CRC_POLYNOMIAL_16B;
|
||||
|
||||
/* The user-defined generating polynomial yields a 16-bit long CRC */
|
||||
CrcHandle->Init.CRCLength = CRC_POLYLENGTH_16B;
|
||||
|
||||
/* The default init value is not used */
|
||||
CrcHandle->Init.DefaultInitValueUse = DEFAULT_INIT_VALUE_DISABLE;
|
||||
|
||||
/* User init value is used instead */
|
||||
CrcHandle->Init.InitValue = CRC_INIT_VALUE;
|
||||
|
||||
/* The input data are inverted by word */
|
||||
CrcHandle->Init.InputDataInversionMode = CRC_INPUTDATA_INVERSION_NONE;
|
||||
/* The bit reversal is done on a full word basis.
|
||||
|
||||
The input stream yielded by CRC16_DATA8[] is the sequence of
|
||||
bytes 0x4D, 0x3C, 0x2B, 0x1A, 0xBE, 0x71, ...
|
||||
meaning that the first word written in the CRC DR register is
|
||||
0x4D3C2B1A.
|
||||
|
||||
Bit reversal done by the hardware on the full word leads to the actual
|
||||
CRC processing of
|
||||
0x58D43CB2.
|
||||
|
||||
Similarly, the second word written in the peripheral is 0xBE71C98A, leading to
|
||||
the processing of 0x51938E7D after hardware input data reversal.
|
||||
|
||||
Note that when the software writes less than a word in the peripheral (to minimize the
|
||||
number of write accesses for a given number of bytes), the bit-reversal operation
|
||||
is carried out only on the inputted data.
|
||||
Therefore, the last written data is the last byte 0x5E, processed as 0x7A
|
||||
by the hardware after bit-reversal to wrap-up the CRC computation.
|
||||
|
||||
This means that the field InputDataInversionMode set to CRC_INPUTDATA_INVERSION_WORD
|
||||
applied to {0x4D, 0x3C, 0x2B, 0x1A, 0xBE, 0x71, 0xC9, 0x8A, 0x5E}
|
||||
yields the same result as InputDataInversionMode set to CRC_INPUTDATA_INVERSION_NONE
|
||||
applied to {0x58, 0xD4, 0x3C, 0xB2, 0x51, 0x93, 0x8E, 0x7D, 0x7A}.
|
||||
|
||||
*/
|
||||
|
||||
/* The output data are inverted */
|
||||
CrcHandle->Init.OutputDataInversionMode = CRC_OUTPUTDATA_INVERSION_DISABLE;
|
||||
/* Output data reversal can only be done at bit level.
|
||||
The expected CRC is 0x5043 after output data reversal, meaning
|
||||
that the CRC before the reversal operation is 0xC20A. */
|
||||
|
||||
/* The input data are bytes (8-bit long data) */
|
||||
CrcHandle->InputDataFormat = CRC_INPUTDATA_FORMAT_BYTES;
|
||||
|
||||
/* De-initialize the CRC peripheral */
|
||||
if (HAL_CRC_DeInit(CrcHandle) != HAL_OK)
|
||||
{
|
||||
/* Initialization Error */
|
||||
DEBUG_LOG("*** CRC16_Init: HAL_CRC_DeInit error!\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Then, initialize the CRC handle */
|
||||
if (HAL_CRC_Init(CrcHandle) != HAL_OK)
|
||||
{
|
||||
/* Initialization Error */
|
||||
DEBUG_LOG("*** CRC16_Init: HAL_CRC_Init error!\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0; // init success
|
||||
}
|
||||
|
||||
int8_t HW_CRC16_Update(CRC_HandleTypeDef *CrcHandle, uint8_t *input_data, uint32_t input_len, uint16_t *crc16_out)
|
||||
{
|
||||
/****************************************************************************/
|
||||
/* */
|
||||
/* CRC computation */
|
||||
/* */
|
||||
/****************************************************************************/
|
||||
|
||||
/* Used for storing CRC Value */
|
||||
__IO uint32_t uwCRCValue = 0;
|
||||
|
||||
if (NULL == CrcHandle)
|
||||
{
|
||||
DEBUG_LOG("*** CRC16_Update: CrcHandle null error !\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* The 16-bit long CRC of the 9-byte buffer is computed. After peripheral initialization,
|
||||
the CRC calculator is initialized with the user-defined value that is 0x5ABE.
|
||||
|
||||
The computed CRC is stored in uint32_t uwCRCValue. The 16-bit long CRC is made of
|
||||
uwCRCValue 16 LSB bits. */
|
||||
|
||||
uwCRCValue = HAL_CRC_Accumulate(CrcHandle, (uint32_t *)input_data, input_len);
|
||||
*crc16_out = (uint16_t)(uwCRCValue & 0x0000FFFF);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else // SOFTWARE CRC16
|
||||
|
||||
static uint16_t UpdateCRC16(uint16_t crcIn, uint8_t byte)
|
||||
{
|
||||
uint32_t crc = crcIn;
|
||||
uint32_t in = (uint32_t)byte | (uint32_t)0x100;
|
||||
|
||||
do
|
||||
{
|
||||
crc <<= 1;
|
||||
in <<= 1;
|
||||
if ((in & (uint32_t)0x100) > 0u)
|
||||
{
|
||||
++crc;
|
||||
}
|
||||
if ((crc & (uint32_t)0x10000) > 0u)
|
||||
{
|
||||
crc ^= (uint32_t)0x1021;
|
||||
}
|
||||
} while (!((in & (uint32_t)0x10000) > 0u));
|
||||
return (uint16_t)(crc & (uint32_t)0xffffu);
|
||||
}
|
||||
|
||||
void CRC16_Init(CRC16_Context *inContext)
|
||||
{
|
||||
inContext->crc = 0;
|
||||
}
|
||||
|
||||
|
||||
void CRC16_Update(CRC16_Context *inContext, const uint8_t *inSrc, size_t inLen)
|
||||
{
|
||||
const uint8_t *src = (const uint8_t *) inSrc;
|
||||
const uint8_t *srcEnd = &(src[inLen]);
|
||||
while (src < srcEnd)
|
||||
{
|
||||
inContext->crc = UpdateCRC16(inContext->crc, *src);
|
||||
src++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CRC16_Final(CRC16_Context *inContext, uint16_t *outResult)
|
||||
{
|
||||
inContext->crc = UpdateCRC16(inContext->crc, 0);
|
||||
inContext->crc = UpdateCRC16(inContext->crc, 0);
|
||||
*outResult = inContext->crc & 0xffffu;
|
||||
}
|
||||
|
||||
#endif /* USE_STM32L_CRC */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
@@ -0,0 +1,151 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file checksum_utils.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for checksum_utils.c module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef CHECKSUM_UTILS_H
|
||||
#define CHECKSUM_UTILS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/*cstat -MISRAC2012-* */
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
/*cstat +MISRAC2012-* */
|
||||
|
||||
|
||||
/* NOTE: MUST ENABLE STM32L HARDWARE CRC periph before use this API
|
||||
#define USE_STM32L_CRC
|
||||
*/
|
||||
|
||||
#define htons(U16) ( ((U16 & 0xFF00) >> 8) | ((U16 & 0x00FF) << 8) )
|
||||
|
||||
#ifdef USE_STM32L_CRC
|
||||
/*cstat -MISRAC2012-* */
|
||||
#include "stm32l4xx_hal.h"
|
||||
/*cstat +MISRAC2012-* */
|
||||
#endif /* USE_STM32L_CRC */
|
||||
|
||||
|
||||
/********************* CRC8 MXOS Check **************************************
|
||||
|
||||
******************CRC-8 XMODEM x8+x5+x4+1******************************
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t crc;
|
||||
} CRC8_Context;
|
||||
|
||||
/**
|
||||
* @brief initialize the CRC8 Context
|
||||
*
|
||||
* @param inContext holds CRC8 result
|
||||
*
|
||||
* @retval none
|
||||
*/
|
||||
void CRC8_Init(CRC8_Context *inContext);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Caculate the CRC8 result
|
||||
*
|
||||
* @param inContext holds CRC8 result during caculation process
|
||||
* @param inSrc input data
|
||||
* @param inLen length of input data
|
||||
*
|
||||
* @retval none
|
||||
*/
|
||||
void CRC8_Update(CRC8_Context *inContext, const uint8_t *inSrc, size_t inLen);
|
||||
|
||||
|
||||
/**
|
||||
* @brief output CRC8 result
|
||||
*
|
||||
* @param inContext holds CRC8 result
|
||||
* @param outResutl holds CRC8 final result
|
||||
*
|
||||
* @retval none
|
||||
*/
|
||||
void CRC8_Final(CRC8_Context *inContext, uint8_t *outResult);
|
||||
|
||||
|
||||
/********************* CRC16 MXOS Check **************************************
|
||||
|
||||
******************CRC-16/XMODEM x16+x12+x5+1******************************
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
#ifdef USE_STM32L_CRC
|
||||
|
||||
int8_t HW_CRC16_Init(CRC_HandleTypeDef *CrcHandle);
|
||||
int8_t HW_CRC16_Update(CRC_HandleTypeDef *CrcHandle, uint8_t *input_data, uint32_t input_len, uint16_t *crc16_out);
|
||||
|
||||
#else
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t crc;
|
||||
} CRC16_Context;
|
||||
|
||||
/**
|
||||
* @brief initialize the CRC16 Context
|
||||
*
|
||||
* @param inContext holds CRC16 result
|
||||
*
|
||||
* @retval none
|
||||
*/
|
||||
void CRC16_Init(CRC16_Context *inContext);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Caculate the CRC16 result
|
||||
*
|
||||
* @param inContext holds CRC16 result during caculation process
|
||||
* @param inSrc input data
|
||||
* @param inLen length of input data
|
||||
*
|
||||
* @retval none
|
||||
*/
|
||||
void CRC16_Update(CRC16_Context *inContext, const uint8_t *inSrc, size_t inLen);
|
||||
|
||||
|
||||
/**
|
||||
* @brief output CRC16 result
|
||||
*
|
||||
* @param inContext holds CRC16 result
|
||||
* @param outResutl holds CRC16 final result
|
||||
*
|
||||
* @retval none
|
||||
*/
|
||||
void CRC16_Final(CRC16_Context *inContext, uint16_t *outResult);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CHECKSUM_UTILS_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
@@ -0,0 +1,80 @@
|
||||
SLA0044 Rev5/February 2018
|
||||
|
||||
## Software license agreement
|
||||
|
||||
### __ULTIMATE LIBERTY SOFTWARE LICENSE AGREEMENT__
|
||||
|
||||
BY INSTALLING, COPYING, DOWNLOADING, ACCESSING OR OTHERWISE USING THIS SOFTWARE
|
||||
OR ANY PART THEREOF (AND THE RELATED DOCUMENTATION) FROM STMICROELECTRONICS
|
||||
INTERNATIONAL N.V, SWISS BRANCH AND/OR ITS AFFILIATED COMPANIES
|
||||
(STMICROELECTRONICS), THE RECIPIENT, ON BEHALF OF HIMSELF OR HERSELF, OR ON
|
||||
BEHALF OF ANY ENTITY BY WHICH SUCH RECIPIENT IS EMPLOYED AND/OR ENGAGED AGREES
|
||||
TO BE BOUND BY THIS SOFTWARE LICENSE AGREEMENT.
|
||||
|
||||
Under STMicroelectronics’ intellectual property rights, the redistribution,
|
||||
reproduction and use in source and binary forms of the software or any part
|
||||
thereof, with or without modification, are permitted provided that the following
|
||||
conditions are met:
|
||||
|
||||
1. Redistribution of source code (modified or not) must retain any copyright
|
||||
notice, this list of conditions and the disclaimer set forth below as items 10
|
||||
and 11.
|
||||
|
||||
2. Redistributions in binary form, except as embedded into microcontroller or
|
||||
microprocessor device manufactured by or for STMicroelectronics or a software
|
||||
update for such device, must reproduce any copyright notice provided with the
|
||||
binary code, this list of conditions, and the disclaimer set forth below as
|
||||
items 10 and 11, in documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
3. Neither the name of STMicroelectronics nor the names of other contributors to
|
||||
this software may be used to endorse or promote products derived from this
|
||||
software or part thereof without specific written permission.
|
||||
|
||||
4. This software or any part thereof, including modifications and/or derivative
|
||||
works of this software, must be used and execute solely and exclusively on or in
|
||||
combination with a microcontroller or microprocessor device manufactured by or
|
||||
for STMicroelectronics.
|
||||
|
||||
5. No use, reproduction or redistribution of this software partially or totally
|
||||
may be done in any manner that would subject this software to any Open Source
|
||||
Terms. “Open Source Terms” shall mean any open source license which requires as
|
||||
part of distribution of software that the source code of such software is
|
||||
distributed therewith or otherwise made available, or open source license that
|
||||
substantially complies with the Open Source definition specified at
|
||||
www.opensource.org and any other comparable open source license such as for
|
||||
example GNU General Public License (GPL), Eclipse Public License (EPL), Apache
|
||||
Software License, BSD license or MIT license.
|
||||
|
||||
6. STMicroelectronics has no obligation to provide any maintenance, support or
|
||||
updates for the software.
|
||||
|
||||
7. The software is and will remain the exclusive property of STMicroelectronics
|
||||
and its licensors. The recipient will not take any action that jeopardizes
|
||||
STMicroelectronics and its licensors' proprietary rights or acquire any rights
|
||||
in the software, except the limited rights specified hereunder.
|
||||
|
||||
8. The recipient shall comply with all applicable laws and regulations affecting
|
||||
the use of the software or any part thereof including any applicable export
|
||||
control law or regulation.
|
||||
|
||||
9. Redistribution and use of this software or any part thereof other than as
|
||||
permitted under this license is void and will automatically terminate your
|
||||
rights under this license.
|
||||
|
||||
10. THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS, WHICH ARE
|
||||
DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL
|
||||
STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
11. EXCEPT AS EXPRESSLY PERMITTED HEREUNDER, NO LICENSE OR OTHER RIGHTS, WHETHER
|
||||
EXPRESS OR IMPLIED, ARE GRANTED UNDER ANY PATENT OR OTHER INTELLECTUAL PROPERTY
|
||||
RIGHTS OF STMICROELECTRONICS OR ANY THIRD PARTY.
|
||||
@@ -0,0 +1,38 @@
|
||||
# BSP MXCHIP Wi-Fi Component
|
||||
|
||||

|
||||
|
||||
## Summary
|
||||
|
||||
**STM32Cube** is an STMicroelectronics original initiative to ease developers' life by reducing efforts, time and cost.
|
||||
|
||||
**STM32Cube** covers the overall STM32 products portfolio. It includes a comprehensive embedded software platform delivered for each STM32 series.
|
||||
* The CMSIS modules (core and device) corresponding to the ARM(tm) core implemented in this STM32 product.
|
||||
* The STM32 HAL-LL drivers, an abstraction layer offering a set of APIs ensuring maximized portability across the STM32 portfolio.
|
||||
* The BSP drivers of each evaluation, demonstration or nucleo board provided for this STM32 series.
|
||||
* A consistent set of middleware libraries such as RTOS, USB, FatFS, graphics, touch sensing library...
|
||||
* A full set of software projects (basic examples, applications, and demonstrations) for each board provided for this STM32 series.
|
||||
|
||||
Two models of publication are proposed for the STM32Cube embedded software:
|
||||
* The monolithic **MCU Package**: all STM32Cube software modules of one STM32 series are present (Drivers, Middleware, Projects, Utilities) in the repository (usual name **STM32Cubexx**, xx corresponding to the STM32 series).
|
||||
* The **MCU component**: each STM32Cube software module being part of the STM32Cube MCU Package, is delivered as an individual repository, allowing the user to select and get only the required software functions.
|
||||
|
||||
## Description
|
||||
|
||||
This repository contains the Wi-Fi component driver running on STM32 host for the EMW3080B Wi-Fi module from MXCHIP.
|
||||
|
||||
## Keywords
|
||||
|
||||
WIFI, MXCHIP, EMW3080B, STM32Cube
|
||||
|
||||
## Release note
|
||||
|
||||
Details about the content of this release are available in the release note [here](https://htmlpreview.github.io/?https://github.com/STMicroelectronics/mx_wifi/blob/main/Release_Notes.html).
|
||||
|
||||
## Compatibility information
|
||||
|
||||
Please refer to the repository of the BSP board driver you are using to know which version of this BSP component driver to use. It is **crucial** that you use a consistent set of versions as indicated.
|
||||
|
||||
## Contributing
|
||||
|
||||
STM32 customers and users who want to contribute to this component can follow instructions provided in the [CONTRIBUTING](CONTRIBUTING.md) guide.
|
||||
@@ -0,0 +1,171 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="generator" content="pandoc" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
||||
<title>Release Notes for MX_WIFI Component Driver</title>
|
||||
<style type="text/css">
|
||||
code{white-space: pre-wrap;}
|
||||
span.smallcaps{font-variant: small-caps;}
|
||||
span.underline{text-decoration: underline;}
|
||||
div.column{display: inline-block; vertical-align: top; width: 50%;}
|
||||
</style>
|
||||
<link rel="stylesheet" href="_htmresc/mini-st.css" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
||||
<![endif]-->
|
||||
<link rel="icon" type="image/x-icon" href="_htmresc/favicon.png" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-lg-4">
|
||||
<div class="card fluid">
|
||||
<div class="sectione dark">
|
||||
<center>
|
||||
<h1 id="release-notes-for-mx_wifi-component-driver"><small>Release Notes for</small> <mark>MX_WIFI Component Driver</mark></h1>
|
||||
<p>Copyright © 2020 STMicroelectronics<br />
|
||||
Microcontrollers Division - Application Team</p>
|
||||
<a href="https://www.st.com" class="logo"><img src="_htmresc/st_logo.png" alt="ST logo" /></a>
|
||||
</center>
|
||||
</div>
|
||||
</div>
|
||||
<h1 id="license">License</h1>
|
||||
<p>Licensed by ST under BSD 3-Clause (the “License”). You may not use this package except in compliance with the License.</p>
|
||||
<p>You may obtain a copy of the License at: <a href="https://opensource.org/licenses/BSD-3-Clause">BSD-3-Clause</a></p>
|
||||
<h1 id="purpose">Purpose</h1>
|
||||
<p>This directory contains the MX_WIFI component driver.</p>
|
||||
</div>
|
||||
<div class="col-sm-12 col-lg-8">
|
||||
<h1 id="update-history">Update History</h1>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section1" checked aria-hidden="false"> <label for="collapse-section1" aria-hidden="true">V1.0.4 / 15-May-2020 </label>
|
||||
<div>
|
||||
<h2 id="main-changes">Main changes</h2>
|
||||
<ul>
|
||||
<li>First official release of MX_WIFI WiFi component.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<h1 id="firmware-update-click-to-expand">Firmware update (click to expand)</h1>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section30" aria-hidden="true"> <label for="collapse-section30" aria-hidden="true">Update via UART</label>
|
||||
<div>
|
||||
<p>This section provides you with a step by step procedure to upload the MXCHIP firmware of an MXCHIP Arduino shield using the MXCHIP UART interface.</p>
|
||||
<p>Prerequisites:</p>
|
||||
<ul>
|
||||
<li>The steps described in this document use Tera Term as a terminal emulator. For the firmware update, you should not use a version more recent than 4.85 as you may encounter some issues when using YModem.</li>
|
||||
<li>The material you need to have is:
|
||||
<ul>
|
||||
<li>a USB to TTL connector</li>
|
||||
<li>4 male to female cables with PCX connectors</li>
|
||||
<li>1 female to female cable with PCX connectors <br/><br/></li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
<p>Connect the TTL signals to the MXCHIP Arduino shield: 3.3 V, GND, Tx and Rx and loop the Boot MXCHIP Arduino shield – See the below picture:</p>
|
||||
<p><img src="_htmresc/fwupdate/picture1.png" title="picture1" /></p>
|
||||
<p><br/><br/> Check that the version of your Tera Term is not more recent than 4.85 using the “Help/About Tera Term” … menu:</p>
|
||||
<p><img src="_htmresc/fwupdate/picture2.png" title="picture2" /></p>
|
||||
<p><br/><br/> Open the Setup/Serial port… and set the Port com correcponding to your setup and the other values as follows:</p>
|
||||
<p><img src="_htmresc/fwupdate/picture3.png" title="picture3" /></p>
|
||||
<p><br/><br/> Press the “Reset” button of the MXCHIP Arduino shield. A menu will be displayed in the Tera Term window as in the below picture:</p>
|
||||
<p><img src="_htmresc/fwupdate/picture4.png" title="picture4" /></p>
|
||||
<p><br/><br/> You have to enter this command: 4 -dev 1 -start 0x0 -end 0x160000:</p>
|
||||
<p><img src="_htmresc/fwupdate/picture5.png" title="picture5" /></p>
|
||||
<p><br/><br/> The board is ready to receive the new firmware:</p>
|
||||
<p><img src="_htmresc/fwupdate/picture6.png" title="picture6" /></p>
|
||||
<p><br/> Select YMODEM Sending:</p>
|
||||
<p><img src="_htmresc/fwupdate/picture7.png" title="picture7" /></p>
|
||||
<p><br/><br/> Then select the firmware available under Firmware\Drivers\BSP\Components\mx_wifi\firmware or Firmware\Drivers\BSPv2\Components\mx_wifi\firmware (one option only will be available in your package).</p>
|
||||
<p><br/><br/> The firmware download is about to start. It takes up to around 30 seconds.</p>
|
||||
<p><img src="_htmresc/fwupdate/picture8.png" title="picture8" /></p>
|
||||
<p><br/><br/> The firmware upgrade is started:</p>
|
||||
<p><img src="_htmresc/fwupdate/picture9.png" title="picture9" /></p>
|
||||
<p><br/><br/> The firmware upgrade is completed:</p>
|
||||
<p><img src="_htmresc/fwupdate/picture10.png" title="picture10" /></p>
|
||||
<p><br/> More documentation on the MXCHIP bootloader can be found at <a href="https://en.docs.mxchip.com/#/docs/mxoscharacter/1.Bootloader" class="uri">https://en.docs.mxchip.com/#/docs/mxoscharacter/1.Bootloader</a></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section31" aria-hidden="true"> <label for="collapse-section31" aria-hidden="true">Update via SWD</label>
|
||||
<div>
|
||||
<p>This section provides you with a step by step procedure to upload the MXCHIP firmware of an MXCHIP Arduino shield using the SWD interface.</p>
|
||||
<p>The MXCHIP-FlashTool is a software tool running on PC in order to download a MXCHIP firmware using the SWD interface.</p>
|
||||
<p>The MXCHIP-FlashTool is supported on these PC OS:</p>
|
||||
<ul>
|
||||
<li>Windows 7/10</li>
|
||||
<li>MacOS</li>
|
||||
<li>Linux</li>
|
||||
</ul>
|
||||
<p>And with these debug probes:</p>
|
||||
<ul>
|
||||
<li>J-LINK</li>
|
||||
<li>ST-LINK_V2</li>
|
||||
<li>ST-LINK_V2-1</li>
|
||||
</ul>
|
||||
<p>Prerequisites:</p>
|
||||
<ul>
|
||||
<li>The MXCHIP-Flash tool is to be installed as described into the below “Tool installation” section.</li>
|
||||
<li>The material you need to have is:
|
||||
<ul>
|
||||
<li>A debug probe</li>
|
||||
<li>4 female to female cables with PCX connectors</li>
|
||||
<li>A 3.3 V generator. Another board can be used as shown in the below picture supplying the power via 2 male to male cables with PCX connectors Tool installation:</li>
|
||||
</ul></li>
|
||||
<li>Python3 installation:
|
||||
<ul>
|
||||
<li>Goto the official website to download python: <a href="https://www.python.org/" class="uri">https://www.python.org/</a></li>
|
||||
</ul></li>
|
||||
<li>Download and install the MXCHIP-Flash tool with pip3
|
||||
<ul>
|
||||
<li>run this command: pip3 install mflash -i https://pypi.tuna.tsinghua.edu.cn/simple</li>
|
||||
</ul></li>
|
||||
<li>For Windows only, install the needed USB driver
|
||||
<ul>
|
||||
<li>Download zadig from <a href="https://zadig.akeo.ie" class="uri">https://zadig.akeo.ie</a></li>
|
||||
<li>Run zadig with administrator rights
|
||||
<ul>
|
||||
<li>Select: Options / List All Devices / Bulk interface / Replace Driver</li>
|
||||
</ul></li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
<p>Connect the debug probe to the MXCHIP board</p>
|
||||
<ul>
|
||||
<li>Debug probe VCC to MXCHIP VDD</li>
|
||||
<li>Debug probe DIO to MXCHIP DIO</li>
|
||||
<li>Debug probe SCK to MXCHIP CLK</li>
|
||||
<li>Debug probe GND to MXCHIP GND</li>
|
||||
</ul>
|
||||
<p>Connect the +3.3 V and GND MXCHIP board to a power supply.</p>
|
||||
<p><img src="_htmresc/fwupdate/picture11.png" title="picture11" style="width:60.0%" /></p>
|
||||
<p><br/><br/></p>
|
||||
<p>USB driver verification. Opening your Device Manager (on Windows) you should see the USB driver as per the below picture</p>
|
||||
<p><img src="_htmresc/fwupdate/picture12.png" title="picture12" class="center" /> <br/><br/></p>
|
||||
<p>Download your image</p>
|
||||
<ul>
|
||||
<li>Right click on your bin file to download, select mflash-Download, see next picture
|
||||
<ul>
|
||||
<li>The image to be downloaded shall have the ALL.BIN suffix</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
<p><img src="_htmresc/fwupdate/picture13.png" title="picture13" /> <br/><br/></p>
|
||||
<ul>
|
||||
<li>Select chip: mx1290</li>
|
||||
<li>Select interface: stlink-v2 (or stlink-v2-1/j-link depend on your hardware)</li>
|
||||
<li>Set address: 0</li>
|
||||
</ul>
|
||||
<p><img src="_htmresc/fwupdate/picture14.png" title="picture14" /> <br/><br/></p>
|
||||
<ul>
|
||||
<li>Click download button to start.</li>
|
||||
<li>Wait until the progress bar reaches 100%.</li>
|
||||
</ul>
|
||||
<p><img src="_htmresc/fwupdate/picture15.png" title="picture15" /> <br/><br/></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<footer class="sticky">
|
||||
For complete documentation on <mark>STM32</mark> microcontrollers please visit <a href="http://www.st.com/stm32" class="uri">http://www.st.com/stm32</a>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,31 @@
|
||||
# Report potential product security vulnerabilities
|
||||
|
||||
ST places a high priority on security, and our Product Security Incident
|
||||
Response Team (PSIRT) is committed to rapidly addressing potential security
|
||||
vulnerabilities affecting our products. PSIRT's long history and vast experience
|
||||
in security allows ST to perform clear analyses and provide appropriate guidance
|
||||
on mitigations and solutions when applicable.
|
||||
|
||||
If you wish to report potential security vulnerabilities regarding our products,
|
||||
**please do not report them through public GitHub issues.** Instead, we
|
||||
encourage you to report them to our ST PSIRT following the process described at:
|
||||
**https://www.st.com/content/st_com/en/security/report-vulnerabilities.html**
|
||||
|
||||
### IMPORTANT - READ CAREFULLY:
|
||||
|
||||
STMicroelectronics International N.V., on behalf of itself, its affiliates and
|
||||
subsidiaries, (collectively “ST”) takes all potential security vulnerability
|
||||
reports or other related communications (“Report(s)”) seriously. In order to
|
||||
review Your Report (the terms “You” and “Yours” include your employer, and all
|
||||
affiliates, subsidiaries and related persons or entities) and take actions as
|
||||
deemed appropriate, ST requires that we have the rights and Your permission to
|
||||
do so.
|
||||
|
||||
As such, by submitting Your Report to ST, You agree that You have the right to
|
||||
do so, and You grant to ST the rights to use the Report for purposes related to
|
||||
security vulnerability analysis, testing, correction, patching, reporting and
|
||||
any other related purpose or function.
|
||||
|
||||
By submitting Your Report, You agree that ST’s
|
||||
[Privacy Policy](https://www.st.com/content/st_com/en/common/privacy-portal.html)
|
||||
applies to all related communications.
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 338 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 16 MiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 16 KiB |
@@ -0,0 +1,160 @@
|
||||
@charset "UTF-8";
|
||||
|
||||
/* unvisited link */
|
||||
a:link {
|
||||
color: blue; }
|
||||
|
||||
/* visited link */
|
||||
a:visited {
|
||||
color: purple; }
|
||||
|
||||
div.Section1 {
|
||||
page: Section1;
|
||||
font-family: Arial,Helvetica,sans-serif;
|
||||
width: 90%;
|
||||
margin-left: auto;
|
||||
margin-right: auto; }
|
||||
|
||||
#header {
|
||||
text-align: center; }
|
||||
|
||||
.license_url {
|
||||
text-align: center; }
|
||||
|
||||
.SW_desc {
|
||||
text-align: center; }
|
||||
|
||||
.logo {
|
||||
font-size: 1.75rem; }
|
||||
|
||||
.release_type {
|
||||
font-weight: bold; }
|
||||
|
||||
h1 {
|
||||
font-size: 24pt;
|
||||
font-weight: bold;
|
||||
font-family: Arial,Helvetica,sans-serif;
|
||||
text-align: center;
|
||||
color: #3366ff; }
|
||||
|
||||
h2 {
|
||||
margin: 12pt 0in 3pt;
|
||||
page-break-after: avoid;
|
||||
font-weight: bold;
|
||||
font-family: Arial,Helvetica,sans-serif;
|
||||
background-color: #3366ff;
|
||||
color: white;
|
||||
padding-left: 5px;
|
||||
font-size: 16pt; }
|
||||
|
||||
h3 {
|
||||
margin-left: 0in;
|
||||
font-weight: bold;
|
||||
font-family: Arial,Helvetica,sans-serif;
|
||||
background-color: #3366ff;
|
||||
width: 200px;
|
||||
margin-right: 500pt;
|
||||
color: white;
|
||||
padding-left: 5px;
|
||||
padding-top: 2px;
|
||||
padding-bottom: 2px;
|
||||
font-size: 12pt; }
|
||||
|
||||
h4 {
|
||||
font-family: Arial,Helvetica,sans-serif;
|
||||
font-weight: bold;
|
||||
text-decoration: underline;
|
||||
font-size: 12pt; }
|
||||
|
||||
p {
|
||||
margin: 0px 0px 0px 0in;
|
||||
font-family: Arial,Helvetica,sans-serif;
|
||||
padding-top: 3px;
|
||||
padding-bottom: 3px;
|
||||
font-size: 12pt; }
|
||||
|
||||
ul {
|
||||
font-family: Arial,Helvetica,sans-serif;
|
||||
margin-top: 3px;
|
||||
margin-bottom: 3px;
|
||||
font-size: 10pt; }
|
||||
|
||||
caption {
|
||||
margin-top: 10px;
|
||||
font-family: Arial,Helvetica,sans-serif;
|
||||
font-size: 11pt; }
|
||||
|
||||
hr {
|
||||
width: 100%; }
|
||||
|
||||
.guidance {
|
||||
background-color: #e5b8b7;
|
||||
font-style: italic;
|
||||
font-family: Arial,Helvetica,sans-serif;
|
||||
padding-top: 3px;
|
||||
padding-bottom: 3px;
|
||||
margin-top: 3px;
|
||||
margin-bottom: 3px;
|
||||
font-size: 10pt; }
|
||||
|
||||
.guidance_title {
|
||||
font-style: normal;
|
||||
font-weight: bold;
|
||||
text-decoration: underline;
|
||||
font-family: Arial,Helvetica,sans-serif;
|
||||
font-size: 10pt; }
|
||||
|
||||
.tickets {
|
||||
width: 90%;
|
||||
table-layout: auto;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
border: 2pt solid #9cc2e5;
|
||||
border-collapse: collapse;
|
||||
font-family: Arial,Helvetica,sans-serif;
|
||||
margin-bottom: 3px;
|
||||
margin-top: 3px;
|
||||
font-size: 10pt; }
|
||||
|
||||
.tickets th {
|
||||
border: 2pt solid #9cc2e5;
|
||||
font-size: 12pt;
|
||||
background-color: #39a9dc;
|
||||
color: white;
|
||||
text-align: center;
|
||||
padding: 5px; }
|
||||
|
||||
.tickets td {
|
||||
border: 2pt solid #9cc2e5;
|
||||
min-height: 32px;
|
||||
text-align: left;
|
||||
padding: 5px; }
|
||||
|
||||
tr:nth-child(even) {background-color: #cee2f2;}
|
||||
tr:nth-child(odd) {background-color: #e8f1f9;}
|
||||
|
||||
.topic1 {
|
||||
margin-top: 3px;
|
||||
margin-bottom: 3px;
|
||||
margin-left: 40px; }
|
||||
|
||||
.topic2 {
|
||||
margin-top: 3px;
|
||||
margin-bottom: 3px; }
|
||||
|
||||
.topic3 {
|
||||
margin-top: 3px;
|
||||
margin-bottom: 3px;
|
||||
margin-left: 20px; }
|
||||
|
||||
.footer_text {
|
||||
text-align: center; }
|
||||
|
||||
#purpose {
|
||||
margin-top: 3px;
|
||||
margin-bottom: 3px; }
|
||||
|
||||
#identification {
|
||||
margin-top: 3px;
|
||||
margin-bottom: 3px; }
|
||||
|
||||
|
After Width: | Height: | Size: 18 KiB |
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file ipc_basic_type.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for ipc_basic_type module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef IPC_BASIC_TYPE_H
|
||||
#define IPC_BASIC_TYPE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/*cstat -MISRAC2012-* */
|
||||
#include "stdio.h"
|
||||
#include "string.h"
|
||||
#include "stdlib.h"
|
||||
#include "stdint.h"
|
||||
/*cstat +MISRAC2012-* */
|
||||
|
||||
#include "mx_wifi_conf.h"
|
||||
|
||||
#if MX_WIFI_USE_CMSIS_OS
|
||||
/*cstat -MISRAC2012-* */
|
||||
#include "cmsis_os.h"
|
||||
/*cstat +MISRAC2012-* */
|
||||
#define MX_CALLOC net_calloc
|
||||
#define MX_MALLOC pvPortMalloc
|
||||
#define MX_FREE vPortFree
|
||||
#else
|
||||
#define MX_MALLOC malloc
|
||||
#define MX_CALLOC calloc
|
||||
#define MX_FREE free
|
||||
#endif /* MX_WIFI_USE_CMSIS_OS */
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
IPC_TYPE_NONE = 0, // no more argument
|
||||
IPC_TYPE_DATA, // uint32_t
|
||||
IPC_TYPE_POINTER, // void *
|
||||
};
|
||||
|
||||
#define IPC_BUFFER_SIZE (MX_WIFI_DATA_SIZE + 600)
|
||||
#define MAX_ARGUEMNT_NUM 10
|
||||
|
||||
/* error code */
|
||||
#define IPC_RET_OK (0)
|
||||
#define IPC_RET_ERROR (-1)
|
||||
#define IPC_RET_TIMEOUT (-2)
|
||||
|
||||
typedef int32_t (*ipc_api_t)();
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct
|
||||
{
|
||||
uint8_t eap_type; /* support: EAP_TYPE_PEAP, EAP_TYPE_TTLS, EAP_TYPE_TLS */
|
||||
uint16_t rootca_len; /* not used, set 0*/
|
||||
uint16_t client_cert_len; /* not used, set 0*/
|
||||
uint16_t client_key_len; /* not used, set 0*/
|
||||
} lib_ipc_eap_attr_t;
|
||||
#pragma pack()
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* IPC_BASIC_TYPE_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file lib_ipc_cmd_event_define.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for lib_ipc_cmd_event_define module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef IPC_CMD_EVENT_DEFINE_H
|
||||
#define IPC_CMD_EVENT_DEFINE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "ipc_basic_type.h"
|
||||
|
||||
/* define all command and event index */
|
||||
|
||||
enum
|
||||
{
|
||||
IPC_CMD_START = 0x1000,
|
||||
#define IPC_CMD_API(name) IPC_CMD_ ##name,
|
||||
#include "ipc_cmd_list.h"
|
||||
IPC_CMD_END,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
IPC_EVENT_START = 0x2000,
|
||||
#define IPC_CMD_API(name) IPC_EVENT_ ##name,
|
||||
#include "ipc_event_list.h"
|
||||
IPC_EVENT_END,
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* IPC_CMD_EVENT_DEFINE_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
@@ -0,0 +1,119 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file lib_ipc_cmd_list.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for lib_ipc_cmd_list module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* list all command APIs in this header file */
|
||||
|
||||
/*
|
||||
* test cmd
|
||||
*/
|
||||
|
||||
/* ST send a string to 3080 */
|
||||
IPC_CMD_API(ipc_echo_cmd)
|
||||
|
||||
/*
|
||||
* system cmd
|
||||
*/
|
||||
IPC_CMD_API(system_reboot_cmd)
|
||||
IPC_CMD_API(system_factory_cmd)
|
||||
IPC_CMD_API(system_firmware_version_get_cmd)
|
||||
|
||||
/*
|
||||
* wifi cmd
|
||||
*/
|
||||
IPC_CMD_API(wifi_mac_get_cmd)
|
||||
IPC_CMD_API(wifi_scan_cmd)
|
||||
IPC_CMD_API(wifi_eap_set_rootca_cmd)
|
||||
IPC_CMD_API(wifi_eap_set_client_cert_cmd)
|
||||
IPC_CMD_API(wifi_eap_set_client_key_cmd)
|
||||
IPC_CMD_API(wifi_eap_connect_cmd)
|
||||
IPC_CMD_API(wifi_connect_cmd)
|
||||
IPC_CMD_API(wifi_disconnect_cmd)
|
||||
IPC_CMD_API(wifi_link_info_get_cmd)
|
||||
IPC_CMD_API(wifi_ip_get_cmd)
|
||||
|
||||
IPC_CMD_API(wifi_softap_start_cmd)
|
||||
IPC_CMD_API(wifi_softap_stop_cmd)
|
||||
|
||||
/*
|
||||
* socket cmd
|
||||
*/
|
||||
IPC_CMD_API(socket_gethostbyname_cmd)
|
||||
IPC_CMD_API(socket_ping_cmd)
|
||||
IPC_CMD_API(socket_create_cmd)
|
||||
IPC_CMD_API(socket_setsockopt_cmd)
|
||||
IPC_CMD_API(socket_getsockopt_cmd)
|
||||
IPC_CMD_API(socket_bind_cmd)
|
||||
IPC_CMD_API(socket_listen_cmd)
|
||||
IPC_CMD_API(socket_accept_cmd)
|
||||
IPC_CMD_API(socket_connect_cmd)
|
||||
IPC_CMD_API(socket_send_cmd)
|
||||
IPC_CMD_API(socket_sendto_cmd)
|
||||
IPC_CMD_API(socket_recv_cmd)
|
||||
IPC_CMD_API(socket_recvfrom_cmd)
|
||||
IPC_CMD_API(socket_close_cmd)
|
||||
IPC_CMD_API(socket_shutdown_cmd)
|
||||
|
||||
/*
|
||||
* mDNS
|
||||
*/
|
||||
IPC_CMD_API(mdns_start_cmd)
|
||||
IPC_CMD_API(mdns_stop_cmd)
|
||||
IPC_CMD_API(mdns_announce_service_cmd)
|
||||
IPC_CMD_API(mdns_deannounce_service_cmd)
|
||||
IPC_CMD_API(mdns_deannounce_service_all_cmd)
|
||||
IPC_CMD_API(mdns_iface_state_change_cmd)
|
||||
IPC_CMD_API(mdns_set_hostname_cmd)
|
||||
IPC_CMD_API(mdns_set_txt_rec_cmd)
|
||||
|
||||
/*
|
||||
* TLS
|
||||
*/
|
||||
IPC_CMD_API(tls_set_ver_cmd)
|
||||
IPC_CMD_API(tls_set_client_certificate_cmd)
|
||||
IPC_CMD_API(tls_set_client_private_key_cmd)
|
||||
IPC_CMD_API(tls_connect_cmd)
|
||||
IPC_CMD_API(tls_connect_sni_cmd)
|
||||
IPC_CMD_API(tls_send_cmd)
|
||||
IPC_CMD_API(tls_recv_cmd)
|
||||
IPC_CMD_API(tls_close_cmd)
|
||||
IPC_CMD_API(tls_set_nonblock_cmd)
|
||||
|
||||
/*
|
||||
* WEBSERVER
|
||||
*/
|
||||
IPC_CMD_API(web_start_cmd)
|
||||
IPC_CMD_API(web_stop_cmd)
|
||||
|
||||
/*
|
||||
* FOTA
|
||||
*/
|
||||
IPC_CMD_API(fota_start_cmd)
|
||||
|
||||
#undef IPC_CMD_API
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
@@ -0,0 +1,108 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file lib_ipc_event_list.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for lib_ipc_event_list module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* list ALL event APIs in this header file */
|
||||
|
||||
/* 3080 send a string event to ST */
|
||||
IPC_CMD_API(ipc_echo_event)
|
||||
|
||||
/*
|
||||
* system event
|
||||
*/
|
||||
IPC_CMD_API(system_firmware_version_get_event)
|
||||
|
||||
/*
|
||||
* wifi event
|
||||
*/
|
||||
IPC_CMD_API(wifi_mac_get_event)
|
||||
IPC_CMD_API(wifi_scan_event)
|
||||
IPC_CMD_API(wifi_link_info_get_event)
|
||||
IPC_CMD_API(wifi_ip_get_event)
|
||||
IPC_CMD_API(wifi_status_event)
|
||||
|
||||
IPC_CMD_API(wifi_softap_start_event)
|
||||
IPC_CMD_API(wifi_softap_stop_event)
|
||||
|
||||
/*
|
||||
* socket event
|
||||
*/
|
||||
IPC_CMD_API(socket_gethostbyname_event)
|
||||
IPC_CMD_API(socket_ping_event)
|
||||
IPC_CMD_API(socket_create_event)
|
||||
IPC_CMD_API(socket_setsockopt_event)
|
||||
IPC_CMD_API(socket_getsockopt_event)
|
||||
IPC_CMD_API(socket_bind_event)
|
||||
IPC_CMD_API(socket_listen_event)
|
||||
IPC_CMD_API(socket_accept_event)
|
||||
IPC_CMD_API(socket_connect_event)
|
||||
IPC_CMD_API(socket_send_event)
|
||||
IPC_CMD_API(socket_sendto_event)
|
||||
IPC_CMD_API(socket_recv_event)
|
||||
IPC_CMD_API(socket_recvfrom_event)
|
||||
IPC_CMD_API(socket_close_event)
|
||||
IPC_CMD_API(socket_shutdown_event)
|
||||
|
||||
/*
|
||||
* mDNS
|
||||
*/
|
||||
IPC_CMD_API(mdns_start_event)
|
||||
IPC_CMD_API(mdns_stop_event)
|
||||
IPC_CMD_API(mdns_announce_service_event)
|
||||
IPC_CMD_API(mdns_deannounce_service_event)
|
||||
IPC_CMD_API(mdns_deannounce_service_all_event)
|
||||
IPC_CMD_API(mdns_iface_state_change_event)
|
||||
IPC_CMD_API(mdns_set_hostname_event)
|
||||
IPC_CMD_API(mdns_set_txt_rec_event)
|
||||
|
||||
/*
|
||||
* TLS
|
||||
*/
|
||||
IPC_CMD_API(tls_set_ver_event)
|
||||
IPC_CMD_API(tls_set_client_certificate_event)
|
||||
IPC_CMD_API(tls_set_client_private_key_event)
|
||||
IPC_CMD_API(tls_connect_event)
|
||||
IPC_CMD_API(tls_send_event)
|
||||
IPC_CMD_API(tls_recv_event)
|
||||
IPC_CMD_API(tls_close_event)
|
||||
IPC_CMD_API(tls_set_nonblock_event)
|
||||
|
||||
/*
|
||||
* WEBSERVER
|
||||
*/
|
||||
IPC_CMD_API(web_start_event)
|
||||
IPC_CMD_API(web_stop_event)
|
||||
|
||||
/*
|
||||
* FOTA
|
||||
*/
|
||||
IPC_CMD_API(fota_start_event)
|
||||
IPC_CMD_API(fota_status_event)
|
||||
|
||||
#undef IPC_CMD_API
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
@@ -0,0 +1,203 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file ipc_recv.c
|
||||
* @author MCD Application Team
|
||||
* @brief Host driver IPC recv API of MXCHIP Wi-Fi component.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/*cstat -MISRAC2012-* */
|
||||
#include "stdio.h"
|
||||
#include "stdarg.h"
|
||||
/*cstat +MISRAC2012-* */
|
||||
|
||||
#include "mx_wifi_conf.h"
|
||||
|
||||
#ifndef IPC_MASTER
|
||||
#include "mdebug.h"
|
||||
#endif
|
||||
#include "lib_ipc.h"
|
||||
|
||||
#ifdef IPC_MASTER
|
||||
|
||||
#ifdef IPC_DEBUG
|
||||
#define app_log(format, ...) printf(format, ##__VA_ARGS__);
|
||||
#define custom_print(format, ...) printf(format, ##__VA_ARGS__);
|
||||
#else
|
||||
#define app_log(format, ...)
|
||||
#define custom_print(format, ...)
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifdef IPC_DEBUG
|
||||
#define app_log(format, ...) custom_log("ipc", format, ##__VA_ARGS__)
|
||||
#else
|
||||
#define app_log(format, ...)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
int32_t ipc_api_recv(uint8_t *data, int32_t len)
|
||||
{
|
||||
int32_t i, argnum = 0, ret = -1;
|
||||
uint16_t cmd, point_len, point_num = 0;
|
||||
uint8_t type;
|
||||
uint32_t arg[MAX_ARGUEMNT_NUM];
|
||||
uint32_t point[MAX_ARGUEMNT_NUM];
|
||||
void *p;
|
||||
void *p_arg;
|
||||
|
||||
#ifdef IPC_DEBUG
|
||||
custom_print("IPC RX %d bytes: ", len);
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
custom_print("%02x ", data[i]);
|
||||
}
|
||||
custom_print("\r\n");
|
||||
#endif
|
||||
|
||||
(void)memcpy(&cmd, data, 2);
|
||||
i = 2;
|
||||
|
||||
#ifdef IPC_MASTER
|
||||
if ((cmd >= (uint16_t)IPC_EVENT_END) || (cmd <= (uint16_t)IPC_EVENT_START))
|
||||
{
|
||||
app_log("rx bad event %x !\r\n", cmd);
|
||||
ret = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd -= ((uint16_t)IPC_EVENT_START + (uint16_t)1);
|
||||
#else
|
||||
if ((cmd >= IPC_CMD_END) || (cmd <= IPC_CMD_START))
|
||||
{
|
||||
app_log("rx bad cmd %x !\r\n", cmd);
|
||||
ret = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd -= (IPC_CMD_START + 1);
|
||||
#endif
|
||||
|
||||
while (i < len)
|
||||
{
|
||||
type = data[i];
|
||||
i++;
|
||||
switch (type)
|
||||
{
|
||||
case IPC_TYPE_DATA:
|
||||
(void)memcpy(&arg[argnum], &data[i], 4);
|
||||
argnum++;
|
||||
i += 4;
|
||||
break;
|
||||
case IPC_TYPE_POINTER:
|
||||
(void)memcpy(&point_len, &data[i], 2);
|
||||
i += 2;
|
||||
if (point_len == (uint16_t)0)
|
||||
{
|
||||
arg[argnum] = (uint32_t)NULL;
|
||||
argnum++;
|
||||
arg[argnum] = (uint32_t)0;
|
||||
argnum++;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_arg = MX_MALLOC(point_len);
|
||||
if (NULL == p_arg)
|
||||
{
|
||||
app_log("*** point_len error! malloc failed!!!");
|
||||
/* goto ERR_EXIT */
|
||||
i = len; /* just for break while(i < len) */
|
||||
argnum = -1; /* just for skip next switch(argnum) */
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)memcpy(&(arg[argnum]), &p_arg, sizeof(uint32_t));
|
||||
point[point_num] = arg[argnum];
|
||||
point_num++;
|
||||
(void)memcpy(p_arg, &data[i], point_len);
|
||||
argnum++;
|
||||
arg[argnum] = (uint32_t)point_len;
|
||||
argnum++;
|
||||
}
|
||||
}
|
||||
i += (int32_t)point_len;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (argnum)
|
||||
{
|
||||
case 0:
|
||||
ret = ipc_event_tbl[cmd]();
|
||||
break;
|
||||
case 1:
|
||||
ret = ipc_event_tbl[cmd](arg[0]);
|
||||
break;
|
||||
case 2:
|
||||
ret = ipc_event_tbl[cmd](arg[0], arg[1]);
|
||||
break;
|
||||
case 3:
|
||||
ret = ipc_event_tbl[cmd](arg[0], arg[1], arg[2]);
|
||||
break;
|
||||
case 4:
|
||||
ret = ipc_event_tbl[cmd](arg[0], arg[1], arg[2], arg[3]);
|
||||
break;
|
||||
case 5:
|
||||
ret = ipc_event_tbl[cmd](arg[0], arg[1], arg[2], arg[3], arg[4]);
|
||||
break;
|
||||
case 6:
|
||||
ret = ipc_event_tbl[cmd](arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]);
|
||||
break;
|
||||
case 7:
|
||||
ret = ipc_event_tbl[cmd](arg[0], arg[1], arg[2], arg[3], arg[4], arg[5],
|
||||
arg[6]);
|
||||
break;
|
||||
case 8:
|
||||
ret = ipc_event_tbl[cmd](arg[0], arg[1], arg[2], arg[3], arg[4], arg[5],
|
||||
arg[6], arg[7]);
|
||||
break;
|
||||
case 9:
|
||||
ret = ipc_event_tbl[cmd](arg[0], arg[1], arg[2], arg[3], arg[4], arg[5],
|
||||
arg[6], arg[7], arg[8]);
|
||||
break;
|
||||
case 10:
|
||||
ret = ipc_event_tbl[cmd](arg[0], arg[1], arg[2], arg[3], arg[4], arg[5],
|
||||
arg[6], arg[7], arg[8], arg[9]);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* ERR_EXIT: */
|
||||
for (i = 0; i < (int32_t)point_num; i++)
|
||||
{
|
||||
(void)memcpy(&p, &point[i], sizeof(p));
|
||||
if (NULL != p)
|
||||
{
|
||||
MX_FREE(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
@@ -0,0 +1,181 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file ipc_send.c
|
||||
* @author MCD Application Team
|
||||
* @brief Host driver IPC send API of MXCHIP Wi-Fi component.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/*cstat -MISRAC2012-* */
|
||||
#include "stdio.h"
|
||||
#include "stdarg.h"
|
||||
#include "stdlib.h"
|
||||
/*cstat +MISRAC2012-* */
|
||||
|
||||
#include "mx_wifi_conf.h"
|
||||
|
||||
#ifndef IPC_MASTER
|
||||
#include "mdebug.h"
|
||||
#endif
|
||||
#include "lib_ipc.h"
|
||||
|
||||
#ifdef IPC_MASTER
|
||||
|
||||
#ifdef IPC_DEBUG
|
||||
#define app_log(format, ...) printf(format, ##__VA_ARGS__);
|
||||
#define custom_print(format, ...) printf(format, ##__VA_ARGS__);
|
||||
#else
|
||||
#define app_log(format, ...)
|
||||
#define custom_print(format, ...)
|
||||
#endif
|
||||
#else
|
||||
#ifdef IPC_DEBUG
|
||||
#define app_log(format, ...) custom_log("ipc", format, ##__VA_ARGS__)
|
||||
#else
|
||||
#define app_log(format, ...)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int32_t ipc_api_send(uint16_t cmd, uint8_t arg_type[], ...)
|
||||
{
|
||||
int32_t i = 0, argnum, offset = 0, ret = 0;
|
||||
va_list ap;
|
||||
uint8_t *buf;
|
||||
void *ptmp;
|
||||
int32_t val;
|
||||
void *p;
|
||||
int32_t len;
|
||||
int16_t point_len;
|
||||
|
||||
ptmp = MX_MALLOC(IPC_BUFFER_SIZE);
|
||||
if (ptmp == NULL)
|
||||
{
|
||||
ret = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)memcpy(&buf, &ptmp, sizeof(buf));
|
||||
while (arg_type[i] != (uint8_t)IPC_TYPE_NONE)
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
(void)memcpy(&buf[offset], &cmd, 2);
|
||||
offset += 2;
|
||||
|
||||
argnum = i;
|
||||
|
||||
va_start(ap, arg_type);
|
||||
for (i = 0; i < argnum; i++)
|
||||
{
|
||||
buf[offset] = arg_type[i];
|
||||
offset++;
|
||||
switch (arg_type[i])
|
||||
{
|
||||
case IPC_TYPE_DATA:
|
||||
val = va_arg(ap, int32_t);
|
||||
if ((offset + 4) >= (IPC_BUFFER_SIZE))
|
||||
{
|
||||
app_log("!!!! ERROR !! message(data) too long");
|
||||
va_end(ap);
|
||||
MX_FREE(buf);
|
||||
ret = -1;
|
||||
/* goto EXIT */
|
||||
i = argnum; /* just for break for( i<argnum)*/
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)memcpy(&buf[offset], &val, 4);
|
||||
offset += 4;
|
||||
}
|
||||
break;
|
||||
|
||||
case IPC_TYPE_POINTER:
|
||||
p = va_arg(ap, void *);
|
||||
i++;
|
||||
if (arg_type[i] != (uint8_t)IPC_TYPE_DATA)
|
||||
{
|
||||
app_log("!!!! ERROR !! IPC pointer must follow int32");
|
||||
va_end(ap);
|
||||
MX_FREE(buf);
|
||||
ret = -1;
|
||||
/* goto EXIT */
|
||||
i = argnum; /* just for break for( i<argnum)*/
|
||||
}
|
||||
else
|
||||
{
|
||||
len = va_arg(ap, int32_t);
|
||||
point_len = (int16_t)len;
|
||||
if ((offset + 2 + len) >= (IPC_BUFFER_SIZE))
|
||||
{
|
||||
app_log("!!!! ERROR !! message(pointer) too long");
|
||||
va_end(ap);
|
||||
MX_FREE(buf);
|
||||
ret = -1;
|
||||
/* goto EXIT */
|
||||
i = argnum; /* just for break for( i<argnum)*/
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)memcpy(&buf[offset], &point_len, 2);
|
||||
offset += 2;
|
||||
if (len > 0)
|
||||
{
|
||||
(void)memcpy(&buf[offset], p, (size_t)len);
|
||||
offset += len;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (-1 != ret)
|
||||
{
|
||||
if (offset > IPC_BUFFER_SIZE)
|
||||
{
|
||||
app_log("!!!! ERROR !! message too long");
|
||||
va_end(ap);
|
||||
MX_FREE(buf);
|
||||
ret = -1;
|
||||
/* goto EXIT */
|
||||
}
|
||||
else
|
||||
{
|
||||
va_end(ap);
|
||||
|
||||
#ifdef IPC_DEBUG
|
||||
custom_print("IPC TX %d bytes: ", offset);
|
||||
for (i = 0; i < offset; i++)
|
||||
{
|
||||
custom_print("%02x ", buf[i]);
|
||||
}
|
||||
custom_print("\r\n");
|
||||
#endif
|
||||
|
||||
ret = ipc_output(buf, offset);
|
||||
MX_FREE(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* EXIT: */
|
||||
return ret;
|
||||
}
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
@@ -0,0 +1,327 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file lib_ipc.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for lib_ipc module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef LIB_IPC_H
|
||||
#define LIB_IPC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "ipc_cmd_event_define.h"
|
||||
|
||||
extern ipc_api_t ipc_event_tbl[];
|
||||
|
||||
/******************************************************************************
|
||||
* LIB_IPC API
|
||||
*****************************************************************************/
|
||||
/* ipc packet process(parse and do real ipc cmd/event function),
|
||||
* return 0 if success, < 0 if failed, > 0 means event銆�async cmd to process).*/
|
||||
int32_t ipc_api_recv(uint8_t *data, int32_t len);
|
||||
|
||||
/* send cmd/event data with ipc packet format
|
||||
* return 0: success, <0: error code */
|
||||
int32_t ipc_api_send(uint16_t cmd, uint8_t arg_type[], ...);
|
||||
|
||||
/* low level packet send function called by ipc_api_send,
|
||||
* implemented by user for different io interfaces.
|
||||
* return 0: success, <0: error code */
|
||||
extern int32_t ipc_output(uint8_t *data, int32_t len);
|
||||
|
||||
/*cstat -MISRAC2012-Dir-4.4 */
|
||||
/**
|
||||
* @defgroup MX_WIFI_IPC Raw_CMD
|
||||
* @brief Raw commands & events for MXCHIP Wi-Fi module, see lib_ipc.h
|
||||
* @{
|
||||
*/
|
||||
/*cstat +MISRAC2012-Dir-4.4 */
|
||||
|
||||
/******************************************************************************
|
||||
* COMMAND & EVENTS
|
||||
*****************************************************************************/
|
||||
/*cstat -MISRAC2012-Dir-4.4 */
|
||||
/**
|
||||
* @defgroup MX_WIFI_IPC_ECHO Echo
|
||||
* @brief Raw data echo cmd & events (for testing)
|
||||
* @{
|
||||
*/
|
||||
/*cstat +MISRAC2012-Dir-4.4 */
|
||||
int32_t ipc_echo_cmd(void *arg1, int32_t len, int32_t p_ret_flag);
|
||||
int32_t ipc_echo_event(void *arg1, int32_t len, int32_t p_ret_flag);
|
||||
/*cstat -MISRAC2012-Dir-4.4 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup MX_WIFI_IPC_SYSTEM System
|
||||
* @brief System cmds & events
|
||||
* @{
|
||||
*/
|
||||
/*cstat +MISRAC2012-Dir-4.4 */
|
||||
int32_t system_reboot_cmd(void);
|
||||
int32_t system_factory_cmd(void);
|
||||
int32_t system_firmware_version_get_cmd(int32_t version_buf_addr, int32_t version_buf_len,
|
||||
int32_t ret_addr, int32_t p_ret_flag);
|
||||
int32_t system_firmware_version_get_event(uint8_t *ret_version, int32_t ret_version_len,
|
||||
uint8_t *ret_data, int32_t ret_data_len, int32_t p_ret_flag);
|
||||
/*cstat -MISRAC2012-Dir-4.4 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup MX_WIFI_IPC_WIFI_STATION Station
|
||||
* @brief Wi-Fi station cmds & events
|
||||
* @{
|
||||
*/
|
||||
/*cstat +MISRAC2012-Dir-4.4 */
|
||||
int32_t wifi_mac_get_cmd(int32_t mac_buf_addr, int32_t mac_buf_len,
|
||||
int32_t ret_addr, int32_t p_ret_flag);
|
||||
int32_t wifi_mac_get_event(uint8_t *ret_mac, int32_t ret_mac_len,
|
||||
uint8_t *ret, int32_t ret_len, int32_t p_ret_flag);
|
||||
int32_t wifi_scan_cmd(int32_t mode, void *ssid, int32_t ssid_len, int32_t p_ret_flag);
|
||||
int32_t wifi_scan_event(int32_t num, uint8_t *ap_list, int32_t ap_list_len, int32_t p_ret_flag);
|
||||
|
||||
int wifi_eap_set_rootca_cmd(void *rootca, int rootca_len);
|
||||
int wifi_eap_set_client_cert_cmd(void *client_cert, int client_cert_len);
|
||||
int wifi_eap_set_client_key_cmd(void *client_key, int client_key_len);
|
||||
int wifi_eap_connect_cmd(void *ssid, int ssid_len, void *identity, int identity_len,
|
||||
void *password, int password_len, void *attr, int attr_len,
|
||||
void *ip, int ip_len);
|
||||
int32_t wifi_connect_cmd(const void *ssid, int32_t ssid_len, const void *key, int32_t key_len,
|
||||
void *connect_attr, int32_t connect_attr_len, void *ip_attr, int32_t ip_attr_len);
|
||||
int32_t wifi_disconnect_cmd(void);
|
||||
|
||||
int32_t wifi_link_info_get_cmd(int32_t p_ret_flag);
|
||||
int32_t wifi_link_info_get_event(uint8_t *info, int32_t len, int32_t p_ret_flag);
|
||||
int32_t wifi_ip_get_cmd(int32_t mode, int32_t p_ret_flag);
|
||||
int32_t wifi_ip_get_event(uint8_t *ip, int32_t len, int32_t p_ret_flag);
|
||||
|
||||
int32_t wifi_status_event(int32_t mode, int32_t state);
|
||||
/*cstat -MISRAC2012-Dir-4.4 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup MX_WIFI_IPC_WIFI_SOFTAP SoftAP
|
||||
* @brief Wi-Fi softAP cmds & events
|
||||
* @{
|
||||
*/
|
||||
/*cstat +MISRAC2012-Dir-4.4 */
|
||||
int32_t wifi_softap_start_cmd(void *ssid, int32_t ssid_len, void *key, int32_t key_len, int32_t channel, void *ip_attr,
|
||||
int32_t ip_attr_len,
|
||||
int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t wifi_softap_start_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
int32_t wifi_softap_stop_cmd(int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t wifi_softap_stop_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
/*cstat -MISRAC2012-Dir-4.4 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup MX_WIFI_IPC_SOCKET Socket
|
||||
* @brief Socket cmds & events
|
||||
* @{
|
||||
*/
|
||||
/*cstat +MISRAC2012-Dir-4.4 */
|
||||
int32_t socket_gethostbyname_cmd(const void *hostname, int32_t namelen, int32_t p_host_addr, int32_t host_addr_len,
|
||||
int32_t p_ret_flag);
|
||||
int32_t socket_gethostbyname_event(uint8_t *ret_host_addr, int32_t ret_host_addr_len,
|
||||
int32_t p_ret_flag);
|
||||
int32_t socket_ping_cmd(const void *hostname, int32_t namelen, int32_t count, int32_t delay_ms, int32_t p_ret_buf,
|
||||
int32_t p_ret_flag);
|
||||
int32_t socket_ping_event(uint8_t *ping_result, int32_t result_len, int32_t p_ret_flag);
|
||||
|
||||
int32_t socket_create_cmd(int32_t domain, int32_t type, int32_t protocol, int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t socket_create_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
|
||||
int32_t socket_setsockopt_cmd(int32_t sockfd, int32_t level, int32_t optname, const void *optval, int32_t optlen,
|
||||
int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t socket_setsockopt_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
|
||||
int32_t socket_getsockopt_cmd(int32_t sockfd, int32_t level, int32_t optname, int32_t p_optbuf, int32_t p_optlen,
|
||||
int32_t optlen,
|
||||
int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t socket_getsockopt_event(uint8_t *optval_buf, int32_t optval_len, uint8_t *ret_optlen_buf, int32_t ret_optlen,
|
||||
uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
int32_t socket_bind_cmd(int32_t sockfd, const void *addr, int32_t addrlen, int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t socket_bind_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
int32_t socket_listen_cmd(int32_t sockfd, int32_t n, int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t socket_listen_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
int32_t socket_accept_cmd(int32_t sockfd, int32_t p_addr, int32_t p_addrlen, int32_t addrlen, int32_t p_ret_fd,
|
||||
int32_t p_ret_flag);
|
||||
int32_t socket_accept_event(uint8_t *addr_buf, int32_t addr_buf_len, uint8_t *p_addrlen, int32_t addrlen,
|
||||
uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
int32_t socket_connect_cmd(int32_t sockfd, const void *addr, int32_t addrlen, int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t socket_connect_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
|
||||
int32_t socket_send_cmd(int32_t sockfd, const uint8_t *buffer, size_t size, int32_t flags,
|
||||
int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t socket_send_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
|
||||
int32_t socket_sendto_cmd(int32_t sockfd, const uint8_t *buffer, size_t size, int32_t flags,
|
||||
const void *addr, int32_t addrlen,
|
||||
int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t socket_sendto_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
|
||||
int32_t socket_recv_cmd(int32_t sockfd, int32_t p_buf, size_t size, int32_t flags,
|
||||
int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t socket_recv_event(uint8_t *recv_buf, size_t size,
|
||||
uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
|
||||
int32_t socket_recvfrom_cmd(int32_t sockfd, int32_t p_buf, size_t size, int32_t flags,
|
||||
int32_t p_fromaddr, int32_t p_fromaddr_len, int32_t fromaddr_len,
|
||||
int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t socket_recvfrom_event(uint8_t *recv_buf, size_t size, uint8_t *fromaddr, int32_t fromaddr_size,
|
||||
uint8_t *fromaddr_len_buf, int32_t fromaddr_len_buf_size,
|
||||
uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
|
||||
int32_t socket_shutdown_cmd(int32_t filedes, int32_t how, int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t socket_shutdown_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
int32_t socket_close_cmd(int32_t filedes, int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t socket_close_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
/*cstat -MISRAC2012-Dir-4.4 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup MX_WIFI_IPC_MDNS mDNS
|
||||
* @brief mDNS cmds & events
|
||||
* @{
|
||||
*/
|
||||
/*cstat +MISRAC2012-Dir-4.4 */
|
||||
int32_t mdns_start_cmd(const char *domain, char *hostname, int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t mdns_start_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
int32_t mdns_stop_cmd(int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t mdns_stop_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
|
||||
int32_t mdns_announce_service_cmd(void *service, int32_t service_len, int32_t iface,
|
||||
int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t mdns_announce_service_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
|
||||
int32_t mdns_deannounce_service_cmd(void *service, int32_t service_len, int32_t iface,
|
||||
int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t mdns_deannounce_service_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
|
||||
int32_t mdns_deannounce_service_all_cmd(int32_t iface, int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t mdns_deannounce_service_all_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
|
||||
int32_t mdns_iface_state_change_cmd(int32_t iface, int32_t state, int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t mdns_iface_state_change_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
|
||||
int32_t mdns_set_hostname_cmd(void *hostname, int32_t len, int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t mdns_set_hostname_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
|
||||
int32_t mdns_set_txt_rec_cmd(void *service, int32_t service_len, int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t mdns_set_txt_rec_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
/*cstat -MISRAC2012-Dir-4.4 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup MX_WIFI_IPC_TLS TLS
|
||||
* @brief TLS cmds & events
|
||||
* @{
|
||||
*/
|
||||
/*cstat +MISRAC2012-Dir-4.4 */
|
||||
int32_t tls_set_ver_cmd(int32_t version, int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t tls_set_ver_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
|
||||
int32_t tls_set_client_certificate_cmd(uint8_t *cert, int32_t len, int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t tls_set_client_certificate_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
int32_t tls_set_client_private_key_cmd(uint8_t *key, int32_t len, int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t tls_set_client_private_key_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
|
||||
int32_t tls_connect_cmd(int32_t domain, int32_t type, int32_t protocol,
|
||||
const void *addr, int32_t addrlen,
|
||||
void *ca, int32_t calen, int32_t p_ret, int32_t p_ret_flag);
|
||||
int tls_connect_sni_cmd(const char* sni_servername, int sni_servername_len,
|
||||
const void *addr, int32_t addrlen,
|
||||
void* ca, int calen, int p_ret, int p_ret_flag);
|
||||
int32_t tls_connect_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
|
||||
int32_t tls_send_cmd(int32_t tls, void *data, int32_t len, int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t tls_send_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
|
||||
int32_t tls_recv_cmd(int32_t tls, int32_t p_buf, int32_t len, int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t tls_recv_event(uint8_t *recv_buf, size_t size,
|
||||
uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
|
||||
int32_t tls_close_cmd(int32_t tls, int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t tls_close_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
|
||||
int32_t tls_set_nonblock_cmd(int32_t tls, int32_t nonblock, int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t tls_set_nonblock_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
/*cstat -MISRAC2012-Dir-4.4 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup MX_WIFI_IPC_WEBSERVER Webserver
|
||||
* @brief Webserver cmds & events
|
||||
* @{
|
||||
*/
|
||||
/*cstat +MISRAC2012-Dir-4.4 */
|
||||
int32_t web_start_cmd(int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t web_start_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
|
||||
int32_t web_stop_cmd(int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t web_stop_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
/*cstat -MISRAC2012-Dir-4.4 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup MX_WIFI_IPC_FOTA FOTA
|
||||
* @brief FOTA cmds & events
|
||||
* @{
|
||||
*/
|
||||
/*cstat +MISRAC2012-Dir-4.4 */
|
||||
int32_t fota_start_cmd(const char *url, int32_t url_len, const char *md5, int32_t md5_len,
|
||||
int32_t p_ret, int32_t p_ret_flag);
|
||||
int32_t fota_start_event(uint8_t *ret_buf, int32_t ret_len, int32_t p_ret_flag);
|
||||
int32_t fota_status_event(int32_t status);
|
||||
/*cstat -MISRAC2012-Dir-4.4 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/*cstat +MISRAC2012-Dir-4.4 */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LIB_IPC_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
@@ -0,0 +1,213 @@
|
||||
---
|
||||
pagetitle: Release Notes for MX_WIFI Component Driver
|
||||
lang: en
|
||||
header-includes: <link rel="icon" type="image/x-icon" href="_htmresc/favicon.png" />
|
||||
---
|
||||
|
||||
::: {.row}
|
||||
::: {.col-sm-12 .col-lg-4}
|
||||
|
||||
::: {.card .fluid}
|
||||
::: {.sectione .dark}
|
||||
<center>
|
||||
# <small>Release Notes for</small> <mark>MX_WIFI Component Driver</mark>
|
||||
Copyright © 2020 STMicroelectronics\
|
||||
Microcontrollers Division - Application Team
|
||||
|
||||
[](https://www.st.com){.logo}
|
||||
</center>
|
||||
:::
|
||||
:::
|
||||
|
||||
# License
|
||||
|
||||
Licensed by ST under BSD 3-Clause (the "License"). You may not use this package except in compliance with the License.
|
||||
|
||||
You may obtain a copy of the License at: [BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause)
|
||||
|
||||
|
||||
# Purpose
|
||||
|
||||
This directory contains the MX_WIFI component driver.
|
||||
:::
|
||||
|
||||
::: {.col-sm-12 .col-lg-8}
|
||||
# Update History
|
||||
::: {.collapse}
|
||||
<input type="checkbox" id="collapse-section1" checked aria-hidden="false">
|
||||
<label for="collapse-section1" aria-hidden="true">V1.0.4 / 15-May-2020 </label>
|
||||
<div>
|
||||
|
||||
## Main changes
|
||||
- First official release of MX_WIFI WiFi component.
|
||||
</div>
|
||||
:::
|
||||
|
||||
# Firmware update (click to expand)
|
||||
::: {.collapse}
|
||||
|
||||
<input type="checkbox" id="collapse-section30" aria-hidden="true">
|
||||
<label for="collapse-section30" aria-hidden="true">Update via UART</label>
|
||||
<div>
|
||||
|
||||
This section provides you with a step by step procedure to upload the MXCHIP firmware of an MXCHIP Arduino shield using the MXCHIP UART interface.
|
||||
|
||||
Prerequisites:
|
||||
|
||||
- The steps described in this document use Tera Term as a terminal emulator. For the firmware update, you should not use a version more recent than 4.85 as you may encounter some issues when using YModem.
|
||||
- The material you need to have is:
|
||||
- a USB to TTL connector
|
||||
- 4 male to female cables with PCX connectors
|
||||
- 1 female to female cable with PCX connectors
|
||||
<br/><br/>
|
||||
|
||||
Connect the TTL signals to the MXCHIP Arduino shield: 3.3 V, GND, Tx and Rx and loop the Boot MXCHIP Arduino shield – See the below picture:
|
||||
|
||||

|
||||
|
||||
<br/><br/>
|
||||
Check that the version of your Tera Term is not more recent than 4.85 using the “Help/About Tera Term” … menu:
|
||||
|
||||

|
||||
|
||||
<br/><br/>
|
||||
Open the Setup/Serial port… and set the Port com correcponding to your setup and the other values as follows:
|
||||
|
||||

|
||||
|
||||
<br/><br/>
|
||||
Press the “Reset” button of the MXCHIP Arduino shield. A menu will be displayed in the Tera Term window as in the below picture:
|
||||
|
||||

|
||||
|
||||
<br/><br/>
|
||||
You have to enter this command: 4 -dev 1 -start 0x0 -end 0x160000:
|
||||
|
||||

|
||||
|
||||
<br/><br/>
|
||||
The board is ready to receive the new firmware:
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
Select YMODEM Sending:
|
||||
|
||||

|
||||
|
||||
<br/><br/>
|
||||
Then select the firmware available under Firmware\\Drivers\\BSP\\Components\\mx_wifi\\firmware or Firmware\\Drivers\\BSPv2\\Components\\mx_wifi\\firmware (one option only will be available in your package).
|
||||
|
||||
<br/><br/>
|
||||
The firmware download is about to start. It takes up to around 30 seconds.
|
||||
|
||||

|
||||
|
||||
<br/><br/>
|
||||
The firmware upgrade is started:
|
||||
|
||||

|
||||
|
||||
<br/><br/>
|
||||
The firmware upgrade is completed:
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
More documentation on the MXCHIP bootloader can be found at <https://en.docs.mxchip.com/#/docs/mxoscharacter/1.Bootloader>
|
||||
|
||||
</div>
|
||||
:::
|
||||
|
||||
::: {.collapse}
|
||||
<input type="checkbox" id="collapse-section31" aria-hidden="true">
|
||||
<label for="collapse-section31" aria-hidden="true">Update via SWD</label>
|
||||
<div>
|
||||
|
||||
This section provides you with a step by step procedure to upload the MXCHIP firmware of an MXCHIP Arduino shield using the SWD interface.
|
||||
|
||||
The MXCHIP-FlashTool is a software tool running on PC in order to download a MXCHIP firmware using the SWD interface.
|
||||
|
||||
The MXCHIP-FlashTool is supported on these PC OS:
|
||||
|
||||
- Windows 7/10
|
||||
- MacOS
|
||||
- Linux
|
||||
|
||||
And with these debug probes:
|
||||
|
||||
- J-LINK
|
||||
- ST-LINK_V2
|
||||
- ST-LINK_V2-1
|
||||
|
||||
Prerequisites:
|
||||
|
||||
- The MXCHIP-Flash tool is to be installed as described into the below "Tool installation" section.
|
||||
- The material you need to have is:
|
||||
- A debug probe
|
||||
- 4 female to female cables with PCX connectors
|
||||
- A 3.3 V generator. Another board can be used as shown in the below picture supplying the power via 2 male to male cables with PCX connectors
|
||||
Tool installation:
|
||||
|
||||
- Python3 installation:
|
||||
- Goto the official website to download python: <https://www.python.org/>
|
||||
|
||||
- Download and install the MXCHIP-Flash tool with pip3
|
||||
- run this command: pip3 install mflash -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
|
||||
- For Windows only, install the needed USB driver
|
||||
- Download zadig from <https://zadig.akeo.ie>
|
||||
- Run zadig with administrator rights
|
||||
- Select: Options / List All Devices / Bulk interface / Replace Driver
|
||||
|
||||
Connect the debug probe to the MXCHIP board
|
||||
|
||||
- Debug probe VCC to MXCHIP VDD
|
||||
- Debug probe DIO to MXCHIP DIO
|
||||
- Debug probe SCK to MXCHIP CLK
|
||||
- Debug probe GND to MXCHIP GND
|
||||
|
||||
Connect the +3.3 V and GND MXCHIP board to a power supply.
|
||||
|
||||
{width=60%}
|
||||
|
||||
<br/><br/>
|
||||
|
||||
USB driver verification. Opening your Device Manager (on Windows) you should see the USB driver as per the below picture
|
||||
|
||||
{.center}
|
||||
<br/><br/>
|
||||
|
||||
Download your image
|
||||
|
||||
- Right click on your bin file to download, select mflash-Download, see next picture
|
||||
- The image to be downloaded shall have the ALL.BIN suffix
|
||||
|
||||

|
||||
<br/><br/>
|
||||
|
||||
- Select chip: mx1290
|
||||
- Select interface: stlink-v2 (or stlink-v2-1/j-link depend on your hardware)
|
||||
- Set address: 0
|
||||
|
||||

|
||||
<br/><br/>
|
||||
|
||||
- Click download button to start.
|
||||
- Wait until the progress bar reaches 100%.
|
||||
|
||||

|
||||
<br/><br/>
|
||||
|
||||
</div>
|
||||
:::
|
||||
|
||||
|
||||
|
||||
|
||||
:::
|
||||
:::
|
||||
|
||||
<footer class="sticky">
|
||||
For complete documentation on <mark>STM32</mark> microcontrollers please visit <http://www.st.com/stm32>
|
||||
</footer>
|
||||
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file mx_wifi_conf_template.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for mx_wifi_conf_template module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef MX_WIFI_CONF_TEMPLATE_H
|
||||
#define MX_WIFI_CONF_TEMPLATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* DEBUG LOG */
|
||||
//#define MX_WIFI_API_DEBUG
|
||||
//#define MX_WIFI_IPC_DEBUG
|
||||
//#define MX_WIFI_HCI_DEBUG
|
||||
//#define MX_WIFI_SLIP_DEBUG
|
||||
//#define MX_WIFI_IO_DEBUG
|
||||
|
||||
|
||||
#define MX_WIFI_PRODUCT_NAME ("MXCHIP-WIFI")
|
||||
#define MX_WIFI_PRODUCT_ID ("EMW3080B")
|
||||
|
||||
#ifndef MX_WIFI_USE_SPI
|
||||
#define MX_WIFI_USE_SPI (0)
|
||||
#endif
|
||||
|
||||
#ifndef MX_WIFI_USE_CMSIS_OS
|
||||
#define MX_WIFI_USE_CMSIS_OS (0)
|
||||
#endif
|
||||
|
||||
#ifndef MX_WIFI_UART_BAUDRATE
|
||||
#define MX_WIFI_UART_BAUDRATE (115200*2)
|
||||
#endif
|
||||
|
||||
#ifndef MX_WIFI_DATA_SIZE
|
||||
#define MX_WIFI_DATA_SIZE (1024*2)
|
||||
#endif
|
||||
|
||||
#define MX_WIFI_TIMEOUT (10000)
|
||||
#define MX_WIFI_MAX_SOCKET_NBR (8)
|
||||
#define MX_WIFI_MAX_DETECTED_AP (10)
|
||||
|
||||
#define MX_WIFI_MAX_SSID_NAME_SIZE 32
|
||||
#define MX_WIFI_MAX_PSWD_NAME_SIZE 64
|
||||
|
||||
#define MX_WIFI_PRODUCT_NAME_SIZE 32
|
||||
#define MX_WIFI_PRODUCT_ID_SIZE 32
|
||||
|
||||
#define MX_WIFI_FW_REV_SIZE 24
|
||||
#define MX_WIFI_API_REV_SIZE 16
|
||||
#define MX_WIFI_STACK_REV_SIZE 16
|
||||
#define MX_WIFI_RTOS_REV_SIZE 16
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MX_WIFI_CONF_TEMPLATE_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
@@ -0,0 +1,578 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file mx_wifi_hci.c
|
||||
* @author MCD Application Team
|
||||
* @brief Host driver HCI protocol of MXCHIP Wi-Fi component.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/*cstat -MISRAC2012-* */
|
||||
#include "stdlib.h"
|
||||
/*cstat +MISRAC2012-* */
|
||||
|
||||
#include "mx_wifi_conf.h"
|
||||
#include "mx_wifi_hci.h"
|
||||
#include "mx_wifi_slip.h"
|
||||
#include "CheckSumUtils.h"
|
||||
|
||||
#ifdef MX_WIFI_HCI_DEBUG
|
||||
#define DEBUG_LOG(M, ...) printf(M, ##__VA_ARGS__);
|
||||
#else
|
||||
#define DEBUG_LOG(M, ...)
|
||||
#endif
|
||||
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
#define HCI_RETRY_INTERVAL 100 // wait 100ms for ACK, if no ACK, resend hci frame
|
||||
#ifdef MX_WIFI_HCI_ACK_ENABLE
|
||||
#define HCI_RETRY_MAX 3 // HCI fram max retry 3 times, then drop and return error
|
||||
#else
|
||||
#define HCI_RETRY_MAX 1 // no retry if no ack
|
||||
#endif
|
||||
#define HCI_RECV_QUEUE_SIZE 3 // queue size 3
|
||||
|
||||
|
||||
/*
|
||||
* recv data queue
|
||||
*/
|
||||
typedef struct _hci_recv_data_t
|
||||
{
|
||||
uint16_t len;
|
||||
uint8_t *data;
|
||||
} hci_recv_data_t;
|
||||
|
||||
typedef struct _hci_recv_queue_t
|
||||
{
|
||||
uint16_t num;
|
||||
uint16_t head;
|
||||
uint16_t tail;
|
||||
hci_recv_data_t buf[HCI_RECV_QUEUE_SIZE];
|
||||
} hci_recv_queue_t;
|
||||
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
static phy_tx_func_t hci_phy_send_cb = NULL;
|
||||
static phy_rx_func_t hci_phy_recv_cb = NULL;
|
||||
static event_notify_func_t notify_event_cb = NULL;
|
||||
|
||||
#if MX_WIFI_USE_CMSIS_OS
|
||||
static osMutexId hci_lock_id;
|
||||
#define MX_WIFI_HCI_LOCK(a, to) (osOK == osMutexWait(a, to))
|
||||
#define MX_WIFI_HCI_UNLOCK(a) (osMutexRelease(a))
|
||||
#else
|
||||
#define MX_WIFI_HCI_LOCK(a,to) (true)
|
||||
#define MX_WIFI_HCI_UNLOCK(a)
|
||||
#endif
|
||||
|
||||
#if (MX_WIFI_USE_SPI == 1)
|
||||
static uint8_t spi_recv_buf[MX_WIFI_DATA_SIZE + 600] = {0};
|
||||
#endif
|
||||
|
||||
#if (MX_WIFI_USE_SPI == 0)
|
||||
static uint8_t hci_seq_num = 0;
|
||||
#endif
|
||||
|
||||
static hci_recv_queue_t hci_msg_queue;
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
static void mx_wifi_hci_yield(uint32_t timeout_ms);
|
||||
|
||||
//TODO add lock
|
||||
static int8_t hci_recv_queue_init(hci_recv_queue_t *pqueue)
|
||||
{
|
||||
int8_t rc = -1;
|
||||
|
||||
if (NULL != pqueue)
|
||||
{
|
||||
pqueue->num = 0;
|
||||
pqueue->head = 0;
|
||||
pqueue->tail = 0;
|
||||
for (int32_t i = 0; i < HCI_RECV_QUEUE_SIZE; i++)
|
||||
{
|
||||
pqueue->buf[i].data = NULL;
|
||||
pqueue->buf[i].len = 0;
|
||||
}
|
||||
rc = 0;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int8_t hci_recv_queue_deinit(hci_recv_queue_t *pqueue)
|
||||
{
|
||||
int8_t rc = -1;
|
||||
|
||||
if (NULL != pqueue)
|
||||
{
|
||||
for (int32_t i = 0; i < HCI_RECV_QUEUE_SIZE; i++)
|
||||
{
|
||||
if (NULL != pqueue->buf[i].data)
|
||||
{
|
||||
HCI_FREE(pqueue->buf[i].data);
|
||||
pqueue->buf[i].data = NULL;
|
||||
}
|
||||
pqueue->buf[i].len = 0;
|
||||
}
|
||||
pqueue->num = 0;
|
||||
pqueue->head = 0;
|
||||
pqueue->tail = 0;
|
||||
|
||||
rc = 0;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static uint16_t hci_recv_queue_msg_num(hci_recv_queue_t *pqueue)
|
||||
{
|
||||
return pqueue->num;
|
||||
}
|
||||
|
||||
static int8_t hci_recv_queue_push(hci_recv_queue_t *pqueue, uint8_t *data, uint16_t len)
|
||||
{
|
||||
int8_t rc = -1;
|
||||
uint8_t *pbuf;
|
||||
void *p;
|
||||
|
||||
if ((NULL != pqueue) && (NULL != data) && (len > (uint16_t)0))
|
||||
{
|
||||
if ((uint16_t)HCI_RECV_QUEUE_SIZE == hci_recv_queue_msg_num(pqueue)) // full, delete head data
|
||||
{
|
||||
if (NULL != pqueue->buf[pqueue->head].data)
|
||||
{
|
||||
HCI_FREE(pqueue->buf[pqueue->head].data);
|
||||
pqueue->buf[pqueue->head].data = NULL;
|
||||
}
|
||||
pqueue->buf[pqueue->head].len = 0;
|
||||
pqueue->head = (pqueue->head + (uint16_t)1) % (uint16_t)HCI_RECV_QUEUE_SIZE;
|
||||
}
|
||||
/* add data after tail */
|
||||
p = HCI_MALLOC(len);
|
||||
if (NULL != p)
|
||||
{
|
||||
(void)memcpy(&pbuf, &p, sizeof(pbuf));
|
||||
(void)memcpy(pbuf, data, len);
|
||||
pqueue->buf[pqueue->tail].data = pbuf;
|
||||
pqueue->buf[pqueue->tail].len = len;
|
||||
pqueue->tail = (pqueue->tail + (uint16_t)1) % (uint16_t)HCI_RECV_QUEUE_SIZE;
|
||||
if (pqueue->num < (uint16_t)HCI_RECV_QUEUE_SIZE)
|
||||
{
|
||||
pqueue->num++;
|
||||
}
|
||||
|
||||
rc = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int8_t hci_recv_queue_pop(hci_recv_queue_t *pqueue, uint8_t **pdata, uint16_t *plen)
|
||||
{
|
||||
int8_t rc = -1;
|
||||
|
||||
if ((NULL != pqueue) && (NULL != pdata) && (NULL != plen))
|
||||
{
|
||||
if (hci_recv_queue_msg_num(pqueue) > (uint16_t)0)
|
||||
{
|
||||
*pdata = pqueue->buf[pqueue->head].data;
|
||||
*plen = pqueue->buf[pqueue->head].len;
|
||||
|
||||
pqueue->buf[pqueue->head].data = NULL;
|
||||
pqueue->buf[pqueue->head].len = 0;
|
||||
pqueue->head = (pqueue->head + (uint16_t)1) % (uint16_t)HCI_RECV_QUEUE_SIZE;
|
||||
pqueue->num--;
|
||||
}
|
||||
else
|
||||
{
|
||||
*plen = 0;
|
||||
*pdata = NULL;
|
||||
}
|
||||
|
||||
rc = 0;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int16_t hci_phy_send(uint8_t *data, uint16_t len, uint32_t timeout)
|
||||
{
|
||||
int16_t rc;
|
||||
|
||||
rc = hci_phy_send_cb(data, len, timeout);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int8_t hci_data_process(uint8_t *data, uint16_t len)
|
||||
{
|
||||
int8_t rc;
|
||||
|
||||
rc = hci_recv_queue_push(&hci_msg_queue, data, len);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int8_t hci_ack_process(uint8_t seq)
|
||||
{
|
||||
#ifdef MX_WIFI_HCI_DEBUG
|
||||
DEBUG_LOG("hci_ack_process: seq[%d]\r\n", seq);
|
||||
#endif
|
||||
|
||||
#ifdef MX_WIFI_HCI_ACK_ENABLE
|
||||
if (seq == hci_seq_num)
|
||||
{
|
||||
hci_seq_num++;
|
||||
hci_ack_flag = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG("hci_ack_process: HCI_EVENT_ERROR_OUT_OF_SEQ\r\n");
|
||||
if (NULL != notify_event_cb)
|
||||
{
|
||||
notify_event_cb(HCI_EVENT_ERROR_OUT_OF_SEQ);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
(void)seq;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void hci_event_notify(uint8_t event)
|
||||
{
|
||||
#ifdef MX_WIFI_HCI_DEBUG
|
||||
DEBUG_LOG("hci_event_notify: event[%d]\r\n", event);
|
||||
#endif
|
||||
if (NULL != notify_event_cb)
|
||||
{
|
||||
notify_event_cb(event);
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
||||
|
||||
/* Global functions ----------------------------------------------------------*/
|
||||
/*
|
||||
* @param timeout: in ms
|
||||
* @retval 0: success, <0: errcode, >0: data send/recv len
|
||||
*
|
||||
*/
|
||||
int8_t mx_wifi_hci_init(phy_tx_func_t phy_send_func, phy_rx_func_t phy_recv_func, event_notify_func_t event_cb)
|
||||
{
|
||||
int8_t rc;
|
||||
#if MX_WIFI_USE_CMSIS_OS
|
||||
osMutexDef_t hci_lock;
|
||||
#endif
|
||||
|
||||
hci_phy_send_cb = phy_send_func;
|
||||
hci_phy_recv_cb = phy_recv_func;
|
||||
#if (MX_WIFI_USE_SPI == 1)
|
||||
(void)memset(spi_recv_buf, 0, sizeof(spi_recv_buf));
|
||||
#endif
|
||||
(void)hci_recv_queue_init(&hci_msg_queue);
|
||||
|
||||
#if MX_WIFI_USE_CMSIS_OS
|
||||
#if (osCMSIS < 0x20000U )
|
||||
hci_lock_id = osMutexCreate(&hci_lock);
|
||||
#else
|
||||
hci_lock_id = osMutexNew(&hci_lock);
|
||||
#endif /* osCMSIS < 0x20000U */
|
||||
#endif
|
||||
#if (MX_WIFI_USE_SPI == 1)
|
||||
rc = 0;
|
||||
notify_event_cb = event_cb;
|
||||
#else // UART
|
||||
notify_event_cb = event_cb;
|
||||
hci_seq_num = 0;
|
||||
rc = (int8_t)slip_init();
|
||||
#endif
|
||||
return rc;
|
||||
}
|
||||
|
||||
int8_t mx_wifi_hci_deinit(void)
|
||||
{
|
||||
#if MX_WIFI_USE_CMSIS_OS
|
||||
(void)osMutexDelete(hci_lock_id);
|
||||
#endif
|
||||
|
||||
#if (MX_WIFI_USE_SPI == 0)
|
||||
notify_event_cb = NULL;
|
||||
hci_seq_num = 0;
|
||||
(void)slip_deinit();
|
||||
#endif
|
||||
|
||||
return hci_recv_queue_deinit(&hci_msg_queue);
|
||||
}
|
||||
|
||||
static void mx_wifi_hci_yield(uint32_t timeout_ms)
|
||||
{
|
||||
int16_t rc;
|
||||
|
||||
#if (MX_WIFI_USE_SPI == 1)
|
||||
rc = hci_phy_recv_cb(spi_recv_buf, MX_WIFI_DATA_SIZE + 600, timeout_ms);
|
||||
if (rc > 0)
|
||||
{
|
||||
#ifdef MX_WIFI_HCI_DEBUG
|
||||
DEBUG_LOG("RX HCI(SPI) got %d bytes:\r\n", rc);
|
||||
for (int32_t i = 0; i < rc; i++)
|
||||
{
|
||||
DEBUG_LOG("%02x ", spi_recv_buf[i]);
|
||||
}
|
||||
DEBUG_LOG("\r\n");
|
||||
#endif
|
||||
(void)hci_recv_queue_push(&hci_msg_queue, spi_recv_buf, (uint16_t)rc);
|
||||
}
|
||||
#else // UART
|
||||
uint8_t in_byte = 0;
|
||||
uint32_t tick_start = HAL_GetTick();
|
||||
|
||||
while ((HAL_GetTick() - tick_start) < timeout_ms)
|
||||
{
|
||||
rc = hci_phy_recv_cb(&in_byte, 1, 10); // recv 1byte from phy
|
||||
if (1 == rc)
|
||||
{
|
||||
(void)slip_input_byte(in_byte); // process byte to detect new hci frame ,then push hci data to queue or set ack flag
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int16_t mx_wifi_hci_send(uint8_t *data, uint16_t len, uint32_t timeout)
|
||||
{
|
||||
#ifdef MX_WIFI_HCI_ACK_ENABLE
|
||||
static volatile uint8_t hci_ack_flag = 0;
|
||||
#endif
|
||||
int16_t rc;
|
||||
|
||||
#if (MX_WIFI_USE_SPI == 1)
|
||||
|
||||
#ifdef MX_WIFI_HCI_DEBUG
|
||||
DEBUG_LOG("TX HCI(SPI) %d bytes:\r\n", len);
|
||||
for (int32_t i = 0; i < len; i++)
|
||||
{
|
||||
DEBUG_LOG("%02x ", data[i]);
|
||||
}
|
||||
DEBUG_LOG("\r\n");
|
||||
#endif
|
||||
|
||||
#if MX_WIFI_USE_CMSIS_OS
|
||||
if (MX_WIFI_HCI_LOCK(hci_lock_id, timeout))
|
||||
{
|
||||
rc = hci_phy_send(data, len, timeout);
|
||||
(void)MX_WIFI_HCI_UNLOCK(hci_lock_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = -1;
|
||||
}
|
||||
#else
|
||||
rc = hci_phy_send(data, len, timeout);
|
||||
#endif
|
||||
|
||||
#else /* UART */
|
||||
|
||||
rc = 0;
|
||||
void *pbuf;
|
||||
uint16_t hci_send_retry = 0;
|
||||
#ifdef MX_WIFI_HCI_ACK_ENABLE
|
||||
uint32_t tick_start = 0;
|
||||
#endif
|
||||
|
||||
// prepare hci frame to send
|
||||
int32_t j = 0, sliplen;
|
||||
uint8_t *buff, *slip_buf;
|
||||
|
||||
#ifdef MX_WIFI_HCI_ACK_ENABLE
|
||||
|
||||
#ifdef USE_STM32L_CRC
|
||||
CRC_HandleTypeDef crc; //STM32L CRC
|
||||
#else
|
||||
CRC16_Context crc; // software crc
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
uint16_t crc16 = 0xFFFF;
|
||||
|
||||
#ifdef MX_WIFI_HCI_DEBUG
|
||||
DEBUG_LOG("TX HCI(UART) %d bytes:\r\n", len);
|
||||
for (int32_t i = 0; i < len; i++)
|
||||
{
|
||||
DEBUG_LOG("%02x ", data[i]);
|
||||
}
|
||||
DEBUG_LOG("\r\n");
|
||||
#endif
|
||||
|
||||
pbuf = HCI_MALLOC((size_t)len + (size_t)4);
|
||||
if (pbuf == NULL)
|
||||
{
|
||||
DEBUG_LOG("** ERROR: mx_wifi_hci_send HCI_MALLOC failed !\r\n");
|
||||
rc = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)memcpy(&buff, &pbuf, sizeof(buff));
|
||||
buff[j] = SLIP_DATA;
|
||||
j++;
|
||||
#if MX_WIFI_USE_CMSIS_OS
|
||||
if (!MX_WIFI_HCI_LOCK(hci_lock_id, timeout))
|
||||
{
|
||||
HCI_FREE(buff);
|
||||
rc = -1;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#ifdef MX_WIFI_HCI_ACK_ENABLE
|
||||
buff[j] = hci_seq_num;
|
||||
#else
|
||||
buff[j] = hci_seq_num;
|
||||
hci_seq_num++;
|
||||
#endif
|
||||
j++;
|
||||
(void)memcpy(&buff[j], data, len);
|
||||
j += (int32_t)len;
|
||||
#ifdef MX_WIFI_HCI_ACK_ENABLE
|
||||
#ifdef USE_STM32L_CRC // STM32L4 CRC
|
||||
HW_CRC16_Init(&crc);
|
||||
HW_CRC16_Update(&crc, buff, j, &crc16);
|
||||
crc16 = htons(crc16);
|
||||
#else
|
||||
CRC16_Init(&crc);
|
||||
CRC16_Update(&crc, buff, j);
|
||||
CRC16_Final(&crc, &crc16);
|
||||
crc16 = htons(crc16);
|
||||
#endif
|
||||
#endif // MX_WIFI_HCI_ACK_ENABLE
|
||||
(void)memcpy(&buff[j], &crc16, 2);
|
||||
j += 2;
|
||||
|
||||
slip_buf = slip_transfer(buff, j, &sliplen);
|
||||
HCI_FREE(buff);
|
||||
if (slip_buf == NULL)
|
||||
{
|
||||
DEBUG_LOG("** ERROR: mx_wifi_hci_send slip_buf null !\r\n");
|
||||
#if MX_WIFI_USE_CMSIS_OS
|
||||
(void)MX_WIFI_HCI_UNLOCK(hci_lock_id);
|
||||
#endif
|
||||
rc = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* send hci frame with retry */
|
||||
while (hci_send_retry < (uint16_t)HCI_RETRY_MAX)
|
||||
{
|
||||
// timeout && retry check
|
||||
#ifdef MX_WIFI_HCI_DEBUG
|
||||
if (hci_send_retry > 0)
|
||||
{
|
||||
DEBUG_LOG("hci_phy_send retry %d ...\r\n", hci_send_retry);
|
||||
}
|
||||
#endif
|
||||
hci_send_retry++;
|
||||
|
||||
// frame send
|
||||
#ifdef MX_WIFI_HCI_ACK_ENABLE
|
||||
hci_ack_flag = 0; // clear ack flag
|
||||
#endif
|
||||
rc = hci_phy_send(slip_buf, (uint16_t)sliplen, timeout);
|
||||
if (rc <= 0)
|
||||
{
|
||||
DEBUG_LOG("** ERROR: hci_phy_send rc=%d !\r\n", rc);
|
||||
continue;
|
||||
}
|
||||
#ifndef MX_WIFI_HCI_ACK_ENABLE
|
||||
else
|
||||
{
|
||||
rc = (int16_t)len; // success
|
||||
break;
|
||||
}
|
||||
#else
|
||||
// wait ack
|
||||
tick_start = HAL_GetTick();
|
||||
while ((HAL_GetTick() - tick_start) < HCI_RETRY_INTERVAL)
|
||||
{
|
||||
if (1 == hci_ack_flag)
|
||||
{
|
||||
rc = len; // real user data len
|
||||
hci_send_retry = HCI_RETRY_MAX; /* break outer retry while */
|
||||
break; /* break current */
|
||||
}
|
||||
else
|
||||
{
|
||||
mx_wifi_hci_yield(50);
|
||||
}
|
||||
}
|
||||
|
||||
if (len != rc)
|
||||
{
|
||||
DEBUG_LOG("** ERROR: hci_phy_send ack timeout !\r\n");
|
||||
rc = -1; // failed
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if MX_WIFI_USE_CMSIS_OS
|
||||
(void)MX_WIFI_HCI_UNLOCK(hci_lock_id);
|
||||
#endif
|
||||
HCI_FREE(slip_buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // MX_WIFI_USE_SPI
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int16_t mx_wifi_hci_recv(uint8_t **p_data, uint32_t timeout)
|
||||
{
|
||||
int16_t rc = 0;
|
||||
uint8_t *data_ptr = NULL;
|
||||
uint16_t tmp_len;
|
||||
|
||||
uint32_t tickStart = HAL_GetTick();
|
||||
|
||||
if (NULL != p_data)
|
||||
{
|
||||
#if MX_WIFI_USE_CMSIS_OS
|
||||
if (MX_WIFI_HCI_LOCK(hci_lock_id, timeout))
|
||||
{
|
||||
#endif
|
||||
while ((HAL_GetTick() - tickStart) < timeout)
|
||||
{
|
||||
tmp_len = 0;
|
||||
rc = hci_recv_queue_pop(&hci_msg_queue, &data_ptr, &tmp_len);
|
||||
if ((0 == rc) && (tmp_len > (uint16_t)0))
|
||||
{
|
||||
*p_data = data_ptr;
|
||||
rc = (int16_t)tmp_len;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
mx_wifi_hci_yield(10); // yield if no data
|
||||
rc = 0; // set return data len 0
|
||||
}
|
||||
}
|
||||
#if MX_WIFI_USE_CMSIS_OS
|
||||
(void)MX_WIFI_HCI_UNLOCK(hci_lock_id);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file mx_wifi_hci.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for mx_wifi_hci.c module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef MX_WIFI_HCI_H
|
||||
#define MX_WIFI_HCI_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/*cstat -MISRAC2012-* */
|
||||
#include "stdint.h"
|
||||
#include "string.h"
|
||||
#include "stdbool.h"
|
||||
#include "stdio.h"
|
||||
/*cstat +MISRAC2012-* */
|
||||
|
||||
uint32_t HAL_GetTick(void);
|
||||
/* Exported Constants --------------------------------------------------------*/
|
||||
//#define MX_WIFI_HCI_ACK_ENABLE // comment this out if not need low level hci ack
|
||||
|
||||
/* Exported macro-------------------------------------------------------------*/
|
||||
enum
|
||||
{
|
||||
HCI_EVENT_ERROR_REPEAT_FRAME, /* received a duplicated sequence HCI frame */
|
||||
HCI_EVENT_ERROR_CRC_ERROR, /* received a CRC error HCI frame*/
|
||||
HCI_EVENT_ERROR_OUT_OF_SEQ, /* received an out of sequence HCI frame */
|
||||
|
||||
};
|
||||
|
||||
/* Exported typedef ----------------------------------------------------------*/
|
||||
// PHY tx data
|
||||
typedef int16_t (*phy_tx_func_t)(uint8_t *pdata, uint16_t len, uint32_t timeout);
|
||||
// PHY rx data
|
||||
typedef int16_t (*phy_rx_func_t)(uint8_t *pdata, uint16_t len, uint32_t timeout);
|
||||
// hci event notify
|
||||
typedef void (*event_notify_func_t)(uint8_t event);
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/*
|
||||
* @param timeout: in ms
|
||||
* @retval 0: success, <0: errcode, >0: data send/recv len
|
||||
*
|
||||
*/
|
||||
int8_t mx_wifi_hci_init(phy_tx_func_t phy_send_func, phy_rx_func_t phy_recv_func, event_notify_func_t event_cb);
|
||||
|
||||
int8_t mx_wifi_hci_deinit(void);
|
||||
|
||||
int16_t mx_wifi_hci_send(uint8_t *data, uint16_t len, uint32_t timeout);
|
||||
|
||||
int16_t mx_wifi_hci_recv(uint8_t **p_data, uint32_t timeout);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MX_WIFI_HCI_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file mx_wifi_ipc.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for mx_wifi_ipc.c module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef MX_WIFI_IPC_H
|
||||
#define MX_WIFI_IPC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/*cstat -MISRAC2012-* */
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
/*cstat +MISRAC2012-* */
|
||||
|
||||
#include "mx_wifi_hci.h"
|
||||
|
||||
/* Exported Constants --------------------------------------------------------*/
|
||||
#define MIPC_RET_FLAG_SET (1)
|
||||
#define MIPC_RET_FLAG_CLR (0)
|
||||
|
||||
extern int32_t recv_cnt;
|
||||
/* Exported macro-------------------------------------------------------------*/
|
||||
|
||||
/* Exported typedef ----------------------------------------------------------*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/*
|
||||
* @param timeout: in ms
|
||||
* @retval 0: success, <0: errcode, >0: return data
|
||||
*
|
||||
*/
|
||||
int32_t mipc_init(phy_tx_func_t io_send, phy_rx_func_t io_recv, uint32_t timeout_ms);
|
||||
|
||||
int32_t mipc_deinit(void);
|
||||
|
||||
// new API
|
||||
int32_t mipc_poll(int32_t *p_ret_flag, int32_t *p_ret, uint32_t timeout_ms);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MX_WIFI_IPC_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
@@ -0,0 +1,425 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file mx_wifi_slip.c
|
||||
* @author MCD Application Team
|
||||
* @brief Host driver SLIP protocol of MXCHIP Wi-Fi component.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/*cstat -MISRAC2012-* */
|
||||
#include "stdlib.h"
|
||||
/*cstat +MISRAC2012-* */
|
||||
|
||||
#include "mx_wifi_conf.h"
|
||||
#include "mx_wifi_hci.h"
|
||||
#include "mx_wifi_slip.h"
|
||||
#include "CheckSumUtils.h"
|
||||
|
||||
#ifdef MX_WIFI_SLIP_DEBUG
|
||||
#define DEBUG_LOG(M, ...) printf(M, ##__VA_ARGS__);
|
||||
#else
|
||||
#define DEBUG_LOG(M, ...)
|
||||
#endif
|
||||
|
||||
#define SLIP_BUF_NUM (2)
|
||||
|
||||
enum
|
||||
{
|
||||
SLIP_STATE_IDLE, // NOT START
|
||||
SLIP_STATE_CONTINUE, // receive data to buffer
|
||||
SLIP_STATE_GOT_ESCAPE, // last byte is escape
|
||||
};
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *data;
|
||||
int32_t len;
|
||||
} slip_msg_t;
|
||||
|
||||
static uint8_t *slip_buffer = NULL, *slip_buf_header, buf_busy[SLIP_BUF_NUM];
|
||||
static int32_t slip_index = 0;
|
||||
|
||||
|
||||
static void slip_buf_get(void)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
slip_buffer = NULL;
|
||||
|
||||
for (i = 0; i < SLIP_BUF_NUM; i++)
|
||||
{
|
||||
if (buf_busy[i] == (uint8_t)0)
|
||||
{
|
||||
slip_buffer = &(slip_buf_header[(SLIP_BUFFER_SIZE) * i]);
|
||||
buf_busy[i] = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void slip_buf_free(uint8_t *buf)
|
||||
{
|
||||
int32_t index, addr_pbuf, addr_header;
|
||||
(void)memcpy(&addr_pbuf, &buf, sizeof(addr_pbuf));
|
||||
(void)memcpy(&addr_header, &slip_buf_header, sizeof(addr_header));
|
||||
index = (addr_pbuf - addr_header);
|
||||
|
||||
index /= (SLIP_BUFFER_SIZE);
|
||||
if ((index < 0) || (index >= SLIP_BUF_NUM))
|
||||
{
|
||||
DEBUG_LOG("** ERROR: slip invlid buf %p, not in %p !\r\n", buf, slip_buf_header);
|
||||
}
|
||||
else
|
||||
{
|
||||
buf_busy[index] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t *slip_transfer(uint8_t *data, int32_t len, int32_t *outlen)
|
||||
{
|
||||
int32_t i, inc = 2, j;
|
||||
uint8_t *buff = NULL;
|
||||
void *pbuf;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if ((data[i] == (uint8_t)SLIP_START) || (data[i] == (uint8_t)SLIP_END)
|
||||
|| (data[i] == (uint8_t)SLIP_ESCAPE))
|
||||
{
|
||||
inc++;
|
||||
}
|
||||
}
|
||||
|
||||
pbuf = HCI_MALLOC((size_t)len + (size_t)inc);
|
||||
if (NULL != pbuf)
|
||||
{
|
||||
(void)memcpy(&buff, &pbuf, sizeof(buff));
|
||||
buff[0] = (uint8_t)SLIP_START;
|
||||
j = 1;
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if (data[i] == (uint8_t)SLIP_START)
|
||||
{
|
||||
buff[j] = (uint8_t)SLIP_ESCAPE;
|
||||
j++;
|
||||
buff[j] = (uint8_t)SLIP_ESCAPE_START;
|
||||
j++;
|
||||
}
|
||||
else if (data[i] == (uint8_t)SLIP_END)
|
||||
{
|
||||
buff[j] = (uint8_t)SLIP_ESCAPE;
|
||||
j++;
|
||||
buff[j] = (uint8_t)SLIP_ESCAPE_END;
|
||||
j++;
|
||||
}
|
||||
else if (data[i] == (uint8_t)SLIP_ESCAPE)
|
||||
{
|
||||
buff[j] = (uint8_t)SLIP_ESCAPE;
|
||||
j++;
|
||||
buff[j] = (uint8_t)SLIP_ESCAPE_ES;
|
||||
j++;
|
||||
}
|
||||
else
|
||||
{
|
||||
buff[j] = data[i];
|
||||
j++;
|
||||
}
|
||||
}
|
||||
buff[j] = (uint8_t)SLIP_END;
|
||||
j++;
|
||||
*outlen = j;
|
||||
}
|
||||
|
||||
return buff;
|
||||
}
|
||||
|
||||
#ifdef MX_WIFI_HCI_ACK_ENABLE
|
||||
static void slip_ack(uint8_t seq)
|
||||
{
|
||||
uint8_t ack[8], *slipbuf;
|
||||
int32_t i = 0, sliplen;
|
||||
uint16_t crc16 = 0xFFFF;
|
||||
#ifdef USE_STM32L_CRC // STM32L4 CRC
|
||||
CRC_HandleTypeDef crc;
|
||||
#else
|
||||
CRC16_Context crc; // software crc
|
||||
#endif
|
||||
|
||||
ack[i] = 1;
|
||||
i++;
|
||||
ack[i] = seq;
|
||||
i++;
|
||||
#ifdef USE_STM32L_CRC
|
||||
HW_CRC16_Init(&crc);
|
||||
HW_CRC16_Update(&crc, ack, i, &crc16);
|
||||
crc16 = htons(crc16);
|
||||
#else // software crc
|
||||
CRC16_Init(&crc);
|
||||
CRC16_Update(&crc, ack, i);
|
||||
CRC16_Final(&crc, &crc16);
|
||||
crc16 = htons(crc16);
|
||||
#endif
|
||||
|
||||
memcpy(&ack[i], &crc16, 2);
|
||||
i += 2;
|
||||
slipbuf = slip_transfer(ack, i, &sliplen);
|
||||
if (slipbuf != NULL)
|
||||
{
|
||||
hci_phy_send(slipbuf, sliplen, 200);
|
||||
HCI_FREE(slipbuf);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Create slip buffer, queue and receive thread */
|
||||
int32_t slip_init(void)
|
||||
{
|
||||
int32_t i, ret = 0;
|
||||
void *pbuf;
|
||||
|
||||
slip_index = 0;
|
||||
slip_buffer = NULL;
|
||||
pbuf = HCI_MALLOC(SLIP_BUFFER_SIZE * SLIP_BUF_NUM);
|
||||
(void)memcpy(&slip_buf_header, &pbuf, sizeof(slip_buf_header));
|
||||
if (slip_buf_header == NULL)
|
||||
{
|
||||
DEBUG_LOG("** ERROR: slip init: No memory !\r\n");
|
||||
ret = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < SLIP_BUF_NUM; i++)
|
||||
{
|
||||
buf_busy[i] = 0;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t slip_deinit(void)
|
||||
{
|
||||
if (NULL != slip_buf_header)
|
||||
{
|
||||
HCI_FREE(slip_buf_header);
|
||||
slip_buf_header = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* send frame to slip thread. */
|
||||
static int32_t slip_frame_input(uint8_t *data, int32_t len)
|
||||
{
|
||||
static uint8_t slip_ack_num = 0;
|
||||
int32_t ret = 0;
|
||||
#ifdef MX_WIFI_SLIP_DEBUG
|
||||
int32_t i = 0;
|
||||
#endif
|
||||
|
||||
#ifdef MX_WIFI_HCI_ACK_ENABLE
|
||||
uint16_t crc16 = 0xFFFF;
|
||||
#ifdef USE_STM32L_CRC
|
||||
CRC_HandleTypeDef crc; // STM32L4 CRC
|
||||
#else
|
||||
CRC16_Context crc; // software crc
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (len < 4)
|
||||
{
|
||||
DEBUG_LOG("** ERROR: slip frame too short !\r\n");
|
||||
slip_buf_free(data);
|
||||
ret = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
#ifdef MX_WIFI_HCI_ACK_ENABLE
|
||||
#ifdef USE_STM32L_CRC
|
||||
HW_CRC16_Init(&crc);
|
||||
HW_CRC16_Update(&crc, data, len - 2, &crc16);
|
||||
crc16 = htons(crc16);
|
||||
#else // software crc
|
||||
CRC16_Init(&crc);
|
||||
CRC16_Update(&crc, data, len - 2);
|
||||
CRC16_Final(&crc, &crc16);
|
||||
crc16 = htons(crc16);
|
||||
#endif
|
||||
if (memcmp(&crc16, &data[len - 2], 2) != 0)
|
||||
{
|
||||
DEBUG_LOG("** ERROR: slip CRC mismatch %04x:%02x%02x !\r\n", crc16, data[len - 1], data[len - 2]);
|
||||
slip_buf_free(data);
|
||||
hci_event_notify(HCI_EVENT_ERROR_CRC_ERROR);
|
||||
ret = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif // MX_WIFI_HCI_ACK_ENABLE
|
||||
|
||||
#ifdef MX_WIFI_SLIP_DEBUG
|
||||
DEBUG_LOG("RX SLIP got %d bytes:\r\n", len);
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
DEBUG_LOG("%02x ", data[i]);
|
||||
}
|
||||
DEBUG_LOG("\r\n");
|
||||
#endif
|
||||
|
||||
if (data[0] == (uint8_t)SLIP_DATA)
|
||||
{
|
||||
if (slip_ack_num == (data[1] + (uint8_t)1))
|
||||
{
|
||||
hci_event_notify((uint8_t)HCI_EVENT_ERROR_REPEAT_FRAME);
|
||||
DEBUG_LOG("** ERROR: duplicate HCI frame, seq %d !\r\n", slip_ack_num);
|
||||
}
|
||||
else if (slip_ack_num != data[1])
|
||||
{
|
||||
DEBUG_LOG("** ERROR: slip out of sequence HCI frame, seq %d, ack %d !\r\n", data[1], slip_ack_num);
|
||||
hci_event_notify((uint8_t)HCI_EVENT_ERROR_OUT_OF_SEQ);
|
||||
}
|
||||
else
|
||||
{
|
||||
// correct ack seq
|
||||
}
|
||||
#ifdef MX_WIFI_HCI_ACK_ENABLE
|
||||
slip_ack(data[1]); // always ack
|
||||
#endif
|
||||
if (slip_ack_num != (data[1] + (uint8_t)1)) // ignore duplicate msg
|
||||
{
|
||||
(void)hci_data_process(&data[2], (uint16_t)len - (uint16_t)4);
|
||||
}
|
||||
slip_ack_num = (data[1] + (uint8_t)1);
|
||||
}
|
||||
#ifdef MX_WIFI_HCI_ACK_ENABLE
|
||||
else if (data[0] == SLIP_ACK)
|
||||
{
|
||||
hci_ack_process(data[1]);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
DEBUG_LOG("** ERROR: slip unsupport msg type %02x !\r\n", data[0]);
|
||||
}
|
||||
slip_buf_free(data);
|
||||
#ifdef MX_WIFI_HCI_ACK_ENABLE
|
||||
}
|
||||
#endif /* MX_WIFI_HCI_ACK_ENABLE */
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t slip_input_byte(uint8_t data)
|
||||
{
|
||||
static int32_t slip_state = SLIP_STATE_IDLE;
|
||||
int32_t ret = 0;
|
||||
|
||||
/* get buffer */
|
||||
if (slip_buffer == NULL)
|
||||
{
|
||||
slip_buf_get();
|
||||
}
|
||||
|
||||
/* buffer get failed */
|
||||
if (slip_buffer == NULL)
|
||||
{
|
||||
DEBUG_LOG("** ERROR: slip No buf !\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (slip_index >= (SLIP_BUFFER_SIZE))
|
||||
{
|
||||
slip_index = 0;
|
||||
slip_state = (int32_t)SLIP_STATE_IDLE;
|
||||
}
|
||||
|
||||
switch (slip_state)
|
||||
{
|
||||
case SLIP_STATE_GOT_ESCAPE:
|
||||
if (data == (uint8_t)SLIP_START)
|
||||
{
|
||||
slip_index = 0;
|
||||
}
|
||||
else if (data == (uint8_t)SLIP_ESCAPE_START)
|
||||
{
|
||||
slip_buffer[slip_index] = (uint8_t)SLIP_START;
|
||||
slip_index++;
|
||||
}
|
||||
else if (data == (uint8_t)SLIP_ESCAPE_ES)
|
||||
{
|
||||
slip_buffer[slip_index] = (uint8_t)SLIP_ESCAPE;
|
||||
slip_index++;
|
||||
}
|
||||
else if (data == (uint8_t)SLIP_ESCAPE_END)
|
||||
{
|
||||
slip_buffer[slip_index] = (uint8_t)SLIP_END;
|
||||
slip_index++;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
if ((int32_t)0 == ret)
|
||||
{
|
||||
slip_state = (int32_t)SLIP_STATE_CONTINUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case SLIP_STATE_IDLE:
|
||||
if (data == (uint8_t)SLIP_START)
|
||||
{
|
||||
slip_index = 0;
|
||||
slip_state = (int32_t)SLIP_STATE_CONTINUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case SLIP_STATE_CONTINUE: // continue
|
||||
if (data == (uint8_t)SLIP_START)
|
||||
{
|
||||
slip_index = 0;
|
||||
slip_state = (int32_t)SLIP_STATE_CONTINUE;
|
||||
}
|
||||
else if (data == (uint8_t)SLIP_END)
|
||||
{
|
||||
(void)slip_frame_input(slip_buffer, slip_index);
|
||||
ret = -1;
|
||||
}
|
||||
else if (data == (uint8_t)SLIP_ESCAPE)
|
||||
{
|
||||
slip_state = (int32_t)SLIP_STATE_GOT_ESCAPE;
|
||||
}
|
||||
else
|
||||
{
|
||||
slip_buffer[slip_index] = data;
|
||||
slip_index++;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if ((int32_t)0 != ret)
|
||||
{
|
||||
slip_index = 0;
|
||||
slip_state = (int32_t)SLIP_STATE_IDLE;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file mx_wifi_slip.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for mx_wifi_slip.c module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef MX_WIFI_SLIP_H
|
||||
#define MX_WIFI_SLIP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "mx_wifi_conf.h"
|
||||
|
||||
#if MX_WIFI_USE_CMSIS_OS
|
||||
/*cstat -MISRAC2012-* */
|
||||
#include "cmsis_os.h"
|
||||
/*cstat +MISRAC2012-* */
|
||||
#define HCI_MALLOC pvPortMalloc
|
||||
#define HCI_FREE vPortFree
|
||||
#else
|
||||
#define HCI_MALLOC malloc
|
||||
#define HCI_FREE free
|
||||
#endif /* MX_WIFI_USE_CMSIS_OS */
|
||||
|
||||
#define SLIP_DATA 0
|
||||
#define SLIP_ACK 1
|
||||
enum
|
||||
{
|
||||
SLIP_START = 0xC0,
|
||||
SLIP_END = 0xD0,
|
||||
SLIP_ESCAPE = 0xDB,
|
||||
SLIP_ESCAPE_START = 0xDC,
|
||||
SLIP_ESCAPE_ES = 0xDD,
|
||||
SLIP_ESCAPE_END = 0xDE,
|
||||
};
|
||||
|
||||
#define SLIP_BUFFER_SIZE (MX_WIFI_DATA_SIZE + 600)
|
||||
|
||||
/* transfer hci data to slip data.
|
||||
* return the slip buffer
|
||||
*/
|
||||
uint8_t *slip_transfer(uint8_t *data, int32_t len, int32_t *outlen);
|
||||
|
||||
int16_t hci_phy_send(uint8_t *data, uint16_t len, uint32_t timeout);
|
||||
int8_t hci_data_process(uint8_t *data, uint16_t len);
|
||||
int8_t hci_ack_process(uint8_t seq);
|
||||
void hci_event_notify(uint8_t event);
|
||||
|
||||
/* PHY receive one serial byte to HCI_SLIP*/
|
||||
int32_t slip_input_byte(uint8_t data);
|
||||
int32_t slip_init(void);
|
||||
int32_t slip_deinit(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MX_WIFI_SLIP_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||