Common Update: Better Doxygen Style
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
* History:
|
||||
* [2021-04-28]: Initial edition.
|
||||
*
|
||||
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||
* Copyright(c) 2024 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
@@ -1,33 +1,25 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: A simple circular FIFO bounded queue
|
||||
* @file circ_queue.h
|
||||
* @author FanHao ([email protected])
|
||||
* @brief A simple circular FIFO bounded queue
|
||||
* @version 0.1
|
||||
* @date 2023-02-23
|
||||
* @note Forked from https://github.com/chrismerck/rpa_queue.git
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
* Author: Fan Hao
|
||||
* Date: 2023-02-23 10:29
|
||||
* LastEditors: Fan Hao
|
||||
* LastEditTime: 2023-02-23 12:53
|
||||
* Revisions: Rev 0.0
|
||||
* History:
|
||||
* [2023-02-23]: Initial Version.
|
||||
*
|
||||
* Copyright(c) 2023 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
* NOTE: Forked from https://github.com/chrismerck/rpa_queue.git
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************/
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup Utility
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup CircularQueue
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef CIRC_QUEUE_H
|
||||
#define CIRC_QUEUE_H
|
||||
@@ -36,20 +28,18 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
/**
|
||||
* opaque structure
|
||||
*/
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
void **data;
|
||||
volatile uint32_t nelts; /**< # elements */
|
||||
uint32_t in; /**< next empty location */
|
||||
uint32_t out; /**< next filled location */
|
||||
uint32_t bounds;/**< max size of queue */
|
||||
uint32_t in; /**< next empty location */
|
||||
uint32_t out; /**< next filled location */
|
||||
uint32_t bounds; /**< max size of queue */
|
||||
} CIRC_QUEUE;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* create a FIFO queue
|
||||
* @param queue The new queue
|
||||
@@ -60,8 +50,8 @@ bool CircQueueCreate(CIRC_QUEUE **queue, uint32_t queue_capacity);
|
||||
|
||||
/** free queue memory -- call after destroy
|
||||
* @note we do not free in destroy() to follow pthreads convention
|
||||
*/
|
||||
void CircQueueFree(CIRC_QUEUE * queue);
|
||||
*/
|
||||
void CircQueueFree(CIRC_QUEUE *queue);
|
||||
|
||||
/**
|
||||
* Detects when the CIRC_QUEUE is full. This utility function is expected
|
||||
@@ -86,7 +76,6 @@ bool isCircQueueEmpty(CIRC_QUEUE *queue);
|
||||
*/
|
||||
bool CircQueuePush(CIRC_QUEUE *queue, void *data);
|
||||
|
||||
|
||||
/**
|
||||
* pop/get an object from the queue, blocking if the queue is already empty
|
||||
*
|
||||
@@ -109,3 +98,7 @@ bool CircQueuePop(CIRC_QUEUE *queue, void **data);
|
||||
uint32_t CircQueueSize(CIRC_QUEUE *queue);
|
||||
|
||||
#endif /* CIRC_QUEUE_H */
|
||||
|
||||
/** @} CircularQueue*/
|
||||
|
||||
/** @} Utility*/
|
||||
@@ -1,9 +1,25 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @file clist.h
|
||||
* @author FanHao ([email protected])
|
||||
* @brief A basic list data structure
|
||||
* @version 0.1
|
||||
* @date 2023-02-23
|
||||
* @note Forked from https://github.com/clibs/list
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
//
|
||||
// clist.h
|
||||
//
|
||||
// Copyright (c) 2010 TJ Holowaychuk <[email protected]>
|
||||
//
|
||||
/**
|
||||
* @addtogroup Utility
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup cList
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __CLIST_H__
|
||||
#define __CLIST_H__
|
||||
@@ -116,3 +132,7 @@ extern "C"
|
||||
#endif
|
||||
|
||||
#endif /* __CLIBS_LIST_H__ */
|
||||
|
||||
/** @} cList*/
|
||||
|
||||
/** @} Utility*/
|
||||
@@ -1,20 +1,19 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: Common definitions
|
||||
*
|
||||
* Date: 2023-12-21 16:32
|
||||
* LastEditors: Fan Hao
|
||||
* LastEditTime: 2022-07-16 17:13
|
||||
* Revisions: Rev 0.1
|
||||
* History:
|
||||
* [2023-12-21]: Ensure the code conform ISO C11 standard.
|
||||
* [2022-07-16]: New branch for Dijian.
|
||||
* [2021-11-16]: Initial version.
|
||||
*
|
||||
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
* @file common.h
|
||||
* @author FanHao ([email protected])
|
||||
* @brief Common macros
|
||||
* @version 0.0
|
||||
* @date 2022-07-16
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
/**
|
||||
* @defgroup COMMON_MACRO
|
||||
* @{
|
||||
*/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
#ifndef __COMMON_H_
|
||||
#define __COMMON_H_
|
||||
@@ -47,8 +46,8 @@
|
||||
#endif
|
||||
#if _DEBUG_LEVEL >= 1
|
||||
#define DBG_ERROR(...) __PRINT_BLOCK( \
|
||||
printf("in "__FILE__ \
|
||||
":%d [error]\t", \
|
||||
printf("in "__FILE__ \
|
||||
":%d [error]\t", \
|
||||
__LINE__); \
|
||||
printf(__VA_ARGS__);)
|
||||
#endif
|
||||
@@ -90,3 +89,5 @@
|
||||
/************************** Function Prototypes ******************************/
|
||||
void AppAssert(const char *file, int line);
|
||||
#endif /* __COMMON_H_ */
|
||||
|
||||
/** @} */
|
||||
@@ -1,19 +1,19 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: Error code definitions.
|
||||
* @file common.h
|
||||
* @author FanHao ([email protected])
|
||||
* @brief Common error numbers
|
||||
* @version 0.0
|
||||
* @date 2022-06-18
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
* Author: Fan Hao
|
||||
* Date: 2022-06-18 16:37
|
||||
* LastEditors: Fan Hao
|
||||
* LastEditTime: 2022-06-18 17:12
|
||||
* Revisions: Rev 0.0
|
||||
* History:
|
||||
* [2022-06-18]: Initial version.
|
||||
*
|
||||
* Copyright(c) 2022 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
*
|
||||
******************************************************************************/
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup COMMON_MACRO
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef SRC_ERROR_H_
|
||||
#define SRC_ERROR_H_
|
||||
@@ -24,6 +24,11 @@
|
||||
/********************** Macros and Constants Definitions **********************/
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* @name ERRORNO)
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef SUCCESS
|
||||
#undef SUCCESS
|
||||
#endif
|
||||
@@ -45,3 +50,7 @@
|
||||
#define IS_ERR_VALUE(x) ((x) != SUCCESS)
|
||||
|
||||
#endif // ERROR_H_
|
||||
|
||||
/** @} ERRORNO*/
|
||||
|
||||
/** @} COMMON_MACRO*/
|
||||
@@ -1,41 +1,21 @@
|
||||
/*******************************************************************************
|
||||
* @file util.h
|
||||
* @brief Implementation of utility functions.
|
||||
* @author DBogdan (dragos.bogdan@analog.com)
|
||||
********************************************************************************
|
||||
* Copyright 2018(c) Analog Devices, Inc.
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @file util.h
|
||||
* @author FanHao (hao_fan_bit_ee@163.com)
|
||||
* @brief Utility functions header file
|
||||
* @version 0.0
|
||||
* @date 2023-05-06
|
||||
*
|
||||
* All rights reserved.
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* - Neither the name of Analog Devices, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* - The use of this software may or may not infringe the patent rights
|
||||
* of one or more patent holders. This license does not release you
|
||||
* from the requirement that you obtain separate licenses from these
|
||||
* patent holders to use this software.
|
||||
* - Use of the software either in source or binary form, must be run
|
||||
* on or directly connected to an Analog Devices Inc. component.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, 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.
|
||||
*******************************************************************************/
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @defgroup Utility
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __UTIL_H_
|
||||
#define __UTIL_H_
|
||||
|
||||
@@ -193,3 +173,5 @@ bool crc16_check(uint8_t *buffPtr, uint32_t dataLen, uint32_t crcOffset, uint16_
|
||||
int crc8_gen(uint8_t *buffPtr, uint32_t dataLen, uint16_t poly, uint8_t *crcVal);
|
||||
bool crc8_check(uint8_t *buffPtr, uint32_t dataLen, uint32_t crcOffset, uint16_t poly);
|
||||
#endif // __UTIL_H_
|
||||
|
||||
/** @} */
|
||||
@@ -10,7 +10,7 @@
|
||||
* History:
|
||||
* [2023-05-07]: Initial edition.
|
||||
*
|
||||
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||
* Copyright(c) 2024 Beijing Institute of Technology.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
@@ -1,19 +1,25 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: Functions for framing operations.
|
||||
* @file framing.h
|
||||
* @author FanHao ([email protected])
|
||||
* @brief DF Linklayer framing functions.
|
||||
* @version 0.0
|
||||
* @date 2023-05-06
|
||||
*
|
||||
* Date: 2022-07-16 14:17
|
||||
* LastEditors: Fan Hao
|
||||
* LastEditTime: 2022-07-16 17:11
|
||||
* Revisions: Rev 0.0
|
||||
* History:
|
||||
* [2022-07-16]: Description of modification.
|
||||
*
|
||||
* Copyright(c) 2022 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayer
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayer_Framing
|
||||
* @{
|
||||
*/
|
||||
/***************************** Include Files *********************************/
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
@@ -177,3 +183,7 @@ bool L2_CrcCheck(uint8_t *dataBuff, uint32_t dataLen, L2_CRC_TYPE crcType)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** @} LinkLayer_Framing*/
|
||||
|
||||
/** @} LinkLayer*/
|
||||
|
||||
@@ -1,8 +1,28 @@
|
||||
//
|
||||
// Copyright (C) 2020 OpenSim Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
//
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @file coord.c
|
||||
* @author FanHao ([email protected])
|
||||
* @version 0.0
|
||||
* @date 2023-05-06
|
||||
*
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
/**
|
||||
* @addtogroup LinkLayer
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayerGeometry
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayerGeometry_Coord
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include "coord.h"
|
||||
@@ -209,3 +229,9 @@ COORD Coord_Launch2Inertia(COORD o, COORD p, double A, double B, double we, doub
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/** @} LinkLayerGeometry_Coord */
|
||||
|
||||
/** @} LinkLayerGeometry */
|
||||
|
||||
/** @} LinkLayer */
|
||||
@@ -1,20 +1,36 @@
|
||||
//
|
||||
// Copyright (C) 2020 OpenSim Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
//
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @file coord.h
|
||||
* @author FanHao ([email protected])
|
||||
* @version 0.0
|
||||
* @date 2023-05-06
|
||||
*
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef _COORD_H
|
||||
#define _COORD_H
|
||||
|
||||
/**
|
||||
* @brief Structure for storing 3D coordinates.
|
||||
*
|
||||
* Some comparison and basic arithmetic operators are implemented.
|
||||
*
|
||||
* @ingroup utils
|
||||
* @addtogroup LinkLayer
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup LinkLayerGeometry
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup LinkLayerGeometry_Coord
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @struct Coordinate
|
||||
* @brief Structure for storing 3D coordinates.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
double x;
|
||||
@@ -78,3 +94,9 @@ COORD Coord_GetNormalized(COORD a);
|
||||
double Coord_Angle(COORD a, COORD b);
|
||||
|
||||
#endif
|
||||
|
||||
/** @} LinkLayerGeometry_Coord */
|
||||
|
||||
/** @} LinkLayerGeometry */
|
||||
|
||||
/** @} LinkLayer */
|
||||
|
||||
@@ -1,8 +1,29 @@
|
||||
//
|
||||
// Copyright (C) 2020 OpenSim Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
//
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @file eulerangles.c
|
||||
* @author FanHao ([email protected])
|
||||
* @version 0.0
|
||||
* @date 2023-05-06
|
||||
*
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayer
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayerGeometry
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayerGeometry_EulerAngles
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include "eulerangles.h"
|
||||
@@ -59,3 +80,9 @@ EULERANGLES EulerAngles_GetNormalize(EULERANGLES e)
|
||||
EulerAngles_Normalize(&e);
|
||||
return e;
|
||||
}
|
||||
|
||||
/** @} LinkLayerGeometry_EulerAngles */
|
||||
|
||||
/** @} LinkLayerGeometry */
|
||||
|
||||
/** @} LinkLayer */
|
||||
@@ -1,3 +1,30 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @file eulerangles.h
|
||||
* @author FanHao ([email protected])
|
||||
* @version 0.0
|
||||
* @date 2023-05-06
|
||||
*
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayer
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayerGeometry
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup LinkLayerGeometry_EulerAngles
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __EULERANGLES_H
|
||||
#define __EULERANGLES_H
|
||||
|
||||
@@ -16,6 +43,11 @@
|
||||
* rotation along the Y axis rotates Z into X (leans forward), positive rotation
|
||||
* along the X axis rotates Y into Z (leans right).
|
||||
*/
|
||||
|
||||
/**
|
||||
* @struct EulerAngles
|
||||
* @brief Structure for standard quaternion
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
double alpha; // unit rad
|
||||
@@ -53,3 +85,9 @@ void EulerAngles_Normalize(EULERANGLES *e);
|
||||
EULERANGLES EulerAngles_GetNormalize(EULERANGLES e);
|
||||
|
||||
#endif
|
||||
|
||||
/** @} LinkLayerGeometry_EulerAngles */
|
||||
|
||||
/** @} LinkLayerGeometry */
|
||||
|
||||
/** @} LinkLayer */
|
||||
@@ -1,8 +1,29 @@
|
||||
//
|
||||
// Copyright (C) 2014 OpenSim Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
//
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @file quaternion.c
|
||||
* @author FanHao ([email protected])
|
||||
* @version 0.0
|
||||
* @date 2023-05-06
|
||||
*
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayer
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayerGeometry
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayerGeometry_Quaternion
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
@@ -28,6 +49,7 @@ const SOFT_DOUBLE EPS_DOUBLE = {.raw = 0x3CB0000000000000};
|
||||
|
||||
const QUATERNION QUATERNION_IDENTITY = {1.0, 0.0, 0.0, 0.0};
|
||||
const QUATERNION QUATERNION_NIL = {NAN, NAN, NAN, NAN};
|
||||
|
||||
/** @brief Subtracts two quaternions. */
|
||||
QUATERNION Quaternion_Sub(QUATERNION q1, QUATERNION q2)
|
||||
{
|
||||
@@ -450,3 +472,9 @@ QUATERNION Quaternion_Slerp(QUATERNION q1, QUATERNION q2, double t)
|
||||
return Quaternion_Lerp(q1, q3, t);
|
||||
}
|
||||
}
|
||||
|
||||
/** @} LinkLayerGeometry_Quaternion */
|
||||
|
||||
/** @} LinkLayerGeometry */
|
||||
|
||||
/** @} LinkLayer */
|
||||
@@ -1,3 +1,29 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @file quaternion.h
|
||||
* @author FanHao ([email protected])
|
||||
* @version 0.0
|
||||
* @date 2023-05-06
|
||||
*
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayer
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayerGeometry
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup LinkLayerGeometry_Quaternion
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __QUATERNION_H
|
||||
#define __QUATERNION_H
|
||||
@@ -5,7 +31,10 @@
|
||||
#include "coord.h"
|
||||
#include "eulerangles.h"
|
||||
|
||||
// borrowed and adapted from https://github.com/MegaManSE/willperone/blob/master/Math/quaternion.h
|
||||
/**
|
||||
* @struct Quaternion
|
||||
* @brief Structure for standard quaternion
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
double s;
|
||||
@@ -107,3 +136,9 @@ QUATERNION Quaternion_Lerp(QUATERNION q1, QUATERNION q2, double t);
|
||||
QUATERNION Quaternion_Slerp(QUATERNION q1, QUATERNION q2, double t);
|
||||
|
||||
#endif
|
||||
|
||||
/** @} LinkLayerGeometry_Quaternion */
|
||||
|
||||
/** @} LinkLayerGeometry */
|
||||
|
||||
/** @} LinkLayer */
|
||||
@@ -1,19 +1,21 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: A brief description of this file
|
||||
* @file link_layer.c
|
||||
* @author FanHao ([email protected])
|
||||
* @brief DF Linklayer implementation file.
|
||||
* @version 0.1
|
||||
* @date 2023-05-06
|
||||
*
|
||||
* Date: 2021-11-13 13:32
|
||||
* LastEditTime: 2021-11-23 10:57
|
||||
* Revisions: Rev 0.0
|
||||
* History:
|
||||
* [2021-11-23]: Initial version.
|
||||
* [2022-03-28]: Add bre test mode.
|
||||
*
|
||||
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayer
|
||||
* @{
|
||||
*/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -43,6 +45,18 @@ static void L2_SetSlotNum(L2_INST *instPtr, uint32_t newSlotNum);
|
||||
static void L2_SetFrameNum(L2_INST *instPtr, uint32_t newFrameNum);
|
||||
static void L2_UpdateSlotNum(L2_INST *instPtr);
|
||||
static void L2_DataAvailUpdate(L2_INST *instPtr, bool status);
|
||||
static void L2_FrameStateUpdate(L2_INST *instPtr);
|
||||
|
||||
/**
|
||||
* @brief Shift L2 status record.(newval->next->curr->last)
|
||||
*/
|
||||
inline void L2_RcdShift(L2_RCD *rcd, int32_t netxVal)
|
||||
{
|
||||
ASSERT(rcd != NULL);
|
||||
rcd->last = rcd->curr;
|
||||
rcd->curr = rcd->next;
|
||||
rcd->next = netxVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief helper function to update linkelayer state
|
||||
@@ -102,6 +116,79 @@ static inline void L2_DataAvailUpdate(L2_INST *instPtr, bool status)
|
||||
instPtr->dataAvail = status;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Update L2 frame state, check if there is any valid L2 frame data in
|
||||
* data buffer, update receive frame status.
|
||||
*
|
||||
* @param instPtr a pointer to linklayer instance
|
||||
*
|
||||
* @return NONE.
|
||||
*
|
||||
******************************************************************************/
|
||||
static void L2_FrameStateUpdate(L2_INST *instPtr)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
PHY_INST *phyRef = instPtr->config.phyInstPtr;
|
||||
bool isValid;
|
||||
L2_FRAME_TYPE recvType = L2_GetLastOptFrameType(instPtr);
|
||||
// Update frame state.
|
||||
if (Phy_IsFrameValid(phyRef) == false)
|
||||
{
|
||||
L2_DataAvailUpdate(instPtr, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG_INFO("A frame received, checking data validation...\n");
|
||||
DBG_INFO("Last frame type is: %" PRId32 ".\n", instPtr->frame.last);
|
||||
Phy_RetrieveRecvData(phyRef, instPtr->recvPktData);
|
||||
instPtr->log.frameRecv++;
|
||||
|
||||
// Update frame state.
|
||||
switch (recvType)
|
||||
{
|
||||
case L2_SCAN_FRAME:
|
||||
case L2_ADV_FRAME:
|
||||
isValid = L2_CrcCheck(instPtr->recvPktData, L2_ADV_PACK_LEN, L2_CRC16_1021);
|
||||
instPtr->log.advRecvCnt++;
|
||||
instPtr->log.advCorrectCnt = isValid ? instPtr->log.advCorrectCnt + 1 : instPtr->log.advCorrectCnt;
|
||||
break;
|
||||
case L2_CFM_FRAME:
|
||||
isValid = L2_CrcCheck(instPtr->recvPktData, L2_CMF_PACK_LEN, L2_CRC16_1021);
|
||||
instPtr->log.cfmRecvCnt++;
|
||||
instPtr->log.cfmCorrectCnt = isValid ? instPtr->log.cfmCorrectCnt + 1 : instPtr->log.cfmCorrectCnt;
|
||||
break;
|
||||
case L2_SVC_FRAME:
|
||||
#ifndef DATALINK_ENABLE_BERTEST
|
||||
isValid = L2_CrcCheck(instPtr->recvPktData, L2_SVC_PACK_LEN, L2_CRC16_1021);
|
||||
#else
|
||||
isValid = true;
|
||||
#endif
|
||||
instPtr->log.svcRecvCnt++;
|
||||
instPtr->log.svcCorrectCnt = isValid ? instPtr->log.svcCorrectCnt + 1 : instPtr->log.svcCorrectCnt;
|
||||
break;
|
||||
|
||||
default:
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
if (isValid)
|
||||
{
|
||||
instPtr->log.frameCorrect++;
|
||||
L2_DataAvailUpdate(instPtr, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
L2_DataAvailUpdate(instPtr, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayer_Utility
|
||||
* @{
|
||||
*/
|
||||
*/
|
||||
/**
|
||||
* @brief Get the current node ID.
|
||||
*/
|
||||
@@ -174,6 +261,14 @@ inline bool L2_isCxn2Net(L2_INST *instPtr)
|
||||
return instPtr->cxn2Net;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get corresponding frame length in byte of L2 frame.
|
||||
*/
|
||||
inline uint32_t L2_GetFrameLen(L2_FRAME_TYPE l2FrameType)
|
||||
{
|
||||
return Phy_GetFrameLen(L2_L2frame2L1frame(l2FrameType));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get last frame number.
|
||||
*/
|
||||
@@ -281,24 +376,6 @@ inline L2_TOR_TYPE L2_GetNextTor(L2_INST *instPtr)
|
||||
return instPtr->tor.next;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Shift L2 status record.(newval->next->curr->last)
|
||||
*
|
||||
* @param instPtr A pointer to physical layer control instance.
|
||||
*
|
||||
* @return NONE.
|
||||
*
|
||||
******************************************************************************/
|
||||
inline void L2_RcdShift(L2_RCD *rcd, int32_t netxVal)
|
||||
{
|
||||
ASSERT(rcd != NULL);
|
||||
rcd->last = rcd->curr;
|
||||
rcd->curr = rcd->next;
|
||||
rcd->next = netxVal;
|
||||
}
|
||||
|
||||
// FIXME:
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Infer last received frame type.
|
||||
@@ -326,291 +403,6 @@ L2_FRAME_TYPE L2_GetLastOptFrameType(L2_INST *instPtr)
|
||||
return L2_NONE_FRAME;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Update L2 frame state, check if there is any valid L2 frame data in
|
||||
* data buffer, update receive frame status.
|
||||
*
|
||||
* @param instPtr a pointer to linklayer instance
|
||||
*
|
||||
* @return NONE.
|
||||
*
|
||||
******************************************************************************/
|
||||
void L2_FrameStateUpdate(L2_INST *instPtr)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
PHY_INST *phyRef = instPtr->config.phyInstPtr;
|
||||
bool isValid;
|
||||
L2_FRAME_TYPE recvType = L2_GetLastOptFrameType(instPtr);
|
||||
// Update frame state.
|
||||
if (Phy_IsFrameValid(phyRef) == false)
|
||||
{
|
||||
L2_DataAvailUpdate(instPtr, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG_INFO("A frame received, checking data validation...\n");
|
||||
DBG_INFO("Last frame type is: %" PRId32 ".\n", instPtr->frame.last);
|
||||
Phy_RetrieveRecvData(phyRef, instPtr->recvPktData);
|
||||
instPtr->log.frameRecv++;
|
||||
|
||||
// Update frame state.
|
||||
switch (recvType)
|
||||
{
|
||||
case L2_SCAN_FRAME:
|
||||
case L2_ADV_FRAME:
|
||||
isValid = L2_CrcCheck(instPtr->recvPktData, L2_ADV_PACK_LEN, L2_CRC16_1021);
|
||||
instPtr->log.advRecvCnt++;
|
||||
instPtr->log.advCorrectCnt = isValid ? instPtr->log.advCorrectCnt + 1 : instPtr->log.advCorrectCnt;
|
||||
break;
|
||||
case L2_CFM_FRAME:
|
||||
isValid = L2_CrcCheck(instPtr->recvPktData, L2_CMF_PACK_LEN, L2_CRC16_1021);
|
||||
instPtr->log.cfmRecvCnt++;
|
||||
instPtr->log.cfmCorrectCnt = isValid ? instPtr->log.cfmCorrectCnt + 1 : instPtr->log.cfmCorrectCnt;
|
||||
break;
|
||||
case L2_SVC_FRAME:
|
||||
#ifndef DATALINK_ENABLE_BERTEST
|
||||
isValid = L2_CrcCheck(instPtr->recvPktData, L2_SVC_PACK_LEN, L2_CRC16_1021);
|
||||
#else
|
||||
isValid = true;
|
||||
#endif
|
||||
instPtr->log.svcRecvCnt++;
|
||||
instPtr->log.svcCorrectCnt = isValid ? instPtr->log.svcCorrectCnt + 1 : instPtr->log.svcCorrectCnt;
|
||||
break;
|
||||
|
||||
default:
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
if (isValid)
|
||||
{
|
||||
instPtr->log.frameCorrect++;
|
||||
L2_DataAvailUpdate(instPtr, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
L2_DataAvailUpdate(instPtr, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Steer antenna beam to specified node.
|
||||
*
|
||||
* @param instPtr a pointer to link layer descriptor instance
|
||||
* @param nodeId destination node
|
||||
*
|
||||
* @return Corresponding frame length
|
||||
* L2_FRAME_NONE_LEN if the frame type code cannot be recognized.
|
||||
*
|
||||
******************************************************************************/
|
||||
// FIXME: To Complete.
|
||||
int32_t L2_SteerBeam2Node(L2_INST *instPtr, uint8_t nodeId)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
int32_t Status;
|
||||
|
||||
COORD myPos, dstPos, beamDir;
|
||||
Status = L2_GetNodePos(instPtr->nodeList, nodeId, &dstPos);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Failed to retrieve position info of node %" PRIu8 ", remain last configuration.\n", nodeId);
|
||||
return EPARAM;
|
||||
}
|
||||
myPos.x = instPtr->sysInfo.posX;
|
||||
myPos.y = instPtr->sysInfo.posY;
|
||||
myPos.z = instPtr->sysInfo.posZ;
|
||||
|
||||
// TODO Check data format
|
||||
EULERANGLES attitudeEuler, antAttitudeEuler;
|
||||
attitudeEuler.alpha = DEG2RAD(instPtr->sysInfo.pitch);
|
||||
attitudeEuler.beta = DEG2RAD(instPtr->sysInfo.yaw);
|
||||
attitudeEuler.gamma = DEG2RAD(instPtr->sysInfo.roll);
|
||||
|
||||
// FIXME: confirm date source.
|
||||
antAttitudeEuler.alpha = DEG2RAD(0);
|
||||
antAttitudeEuler.beta = DEG2RAD(0);
|
||||
antAttitudeEuler.gamma = DEG2RAD(0);
|
||||
|
||||
// TODO Check data format
|
||||
QUATERNION attitude, antAttitude;
|
||||
attitude = Quaternion_FromeEulerAngles(attitudeEuler, EULERANGLES_XYZ);
|
||||
antAttitude = Quaternion_FromeEulerAngles(antAttitudeEuler, EULERANGLES_XYZ);
|
||||
|
||||
// --- --- Algorithm --- ---
|
||||
// TODO Check result validation
|
||||
// Compute beam direction vector
|
||||
beamDir = Coord_Sub(dstPos, myPos);
|
||||
|
||||
// Compute antenna attitude respect to ECEF
|
||||
antAttitude = Quaternion_Mult(attitude, antAttitude);
|
||||
|
||||
// Convert beam direction vector to antenna coordinate
|
||||
beamDir = Quaternion_Rotate(Quaternion_GeInverse(antAttitude), beamDir);
|
||||
// Normalize
|
||||
Coord_Normalize(&beamDir);
|
||||
|
||||
double oAxis, rAxis;
|
||||
oAxis = RAD2DEG(atan2(beamDir.z, beamDir.y));
|
||||
rAxis = RAD2DEG(acos(Coord_Dot(beamDir, COORD_X_AXIS)));
|
||||
Status = Phy_SetBeamAngle(instPtr->config.phyInstPtr, oAxis, rAxis);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Layer 2 setup next slot operation, update current operating frame.
|
||||
*
|
||||
* @param instPtr a pointer to linklayer instance
|
||||
* @param txrxMode tx/rx state for next slot
|
||||
* @param frameType frame type of next slot.
|
||||
*
|
||||
* @return Corresponding frame length
|
||||
* L2_FRAME_NONE_LEN if the frame type code cannot be recognized.
|
||||
*
|
||||
******************************************************************************/
|
||||
int32_t L2_SetupNextSlot(L2_INST *instPtr, L2_TOR_TYPE txrxMode, L2_FRAME_TYPE frameType)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
PHY_INST *phyRef = instPtr->config.phyInstPtr;
|
||||
int32_t Status;
|
||||
if (frameType < L2_SCAN_FRAME || frameType > L2_SVC_FRAME)
|
||||
{
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
// logging
|
||||
if (txrxMode == L2_TOR_TX)
|
||||
{
|
||||
instPtr->log.frameTx++;
|
||||
switch (frameType)
|
||||
{
|
||||
case L2_ADV_FRAME:
|
||||
instPtr->log.advTxCnt++;
|
||||
break;
|
||||
case L2_CFM_FRAME:
|
||||
instPtr->log.cfmTxCnt++;
|
||||
break;
|
||||
case L2_SVC_FRAME:
|
||||
instPtr->log.svcTxCnt++;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (txrxMode == L2_TOR_RX)
|
||||
{
|
||||
instPtr->log.frameRx++;
|
||||
switch (frameType)
|
||||
{
|
||||
case L2_ADV_FRAME:
|
||||
instPtr->log.advRxCnt++;
|
||||
break;
|
||||
case L2_CFM_FRAME:
|
||||
instPtr->log.cfmRxCnt++;
|
||||
break;
|
||||
case L2_SVC_FRAME:
|
||||
instPtr->log.svcRxCnt++;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if _DEBUG_LEVEL >= 3
|
||||
char *torStr = NULL;
|
||||
char *frameStr = NULL;
|
||||
switch (txrxMode)
|
||||
{
|
||||
case L2_TOR_SUSPEND:
|
||||
torStr = "SUSPEND";
|
||||
break;
|
||||
case L2_TOR_TX:
|
||||
torStr = "TX";
|
||||
break;
|
||||
case L2_TOR_RX:
|
||||
torStr = "RX";
|
||||
break;
|
||||
}
|
||||
switch (frameType)
|
||||
{
|
||||
case L2_SCAN_FRAME:
|
||||
frameStr = "Scan";
|
||||
break;
|
||||
case L2_ADV_FRAME:
|
||||
frameStr = "Advertisement";
|
||||
break;
|
||||
case L2_CFM_FRAME:
|
||||
frameStr = "Confirm";
|
||||
break;
|
||||
case L2_SVC_FRAME:
|
||||
frameStr = "Service";
|
||||
break;
|
||||
default:
|
||||
frameStr = "UNKNOWN Frame";
|
||||
break;
|
||||
}
|
||||
DBG_INFO("# Setup Next Slot # [%" PRIu32 "-%" PRIu32 "], %s, %s.\n",
|
||||
instPtr->frameNum.next,
|
||||
instPtr->slotNum.next,
|
||||
torStr, frameStr);
|
||||
#endif
|
||||
|
||||
// Update frame and tx/rx mode record.
|
||||
// Frame types shift (last <- curr <- next)
|
||||
L2_RcdShift(&(instPtr->frame), frameType);
|
||||
L2_RcdShift(&(instPtr->tor), txrxMode);
|
||||
|
||||
TIME_WORD pullTime = {0, 0};
|
||||
pullTime.int_part = TimeCtrl_GetIntCnt(instPtr->config.tmcInstPtr) + 1;
|
||||
Status = Phy_SetTimeWord(phyRef, &pullTime, PHY_TIME_WORD_POLL);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Physical set pull time failed, with error code: %" PRId32 "\n", Status);
|
||||
}
|
||||
|
||||
PHY_TOR_TYPE tor;
|
||||
switch (txrxMode)
|
||||
{
|
||||
case L2_TOR_SUSPEND:
|
||||
tor = PHY_TOR_SUSPEND;
|
||||
break;
|
||||
case L2_TOR_TX:
|
||||
tor = PHY_TOR_TX;
|
||||
break;
|
||||
case L2_TOR_RX:
|
||||
tor = PHY_TOR_RX;
|
||||
break;
|
||||
default:
|
||||
DBG_ERROR("Invalid txrx mode :%" PRId8 ".\n", txrxMode);
|
||||
return EPARAM;
|
||||
}
|
||||
|
||||
Status = Phy_SetupNextSlot(phyRef, tor, L2_L2frame2L1frame(frameType), instPtr->sendPktData);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Physical setup failed, with error code: %" PRId32 "\n", Status);
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Get corresponding frame length in byte of L2 frame.
|
||||
*
|
||||
* @param l2FrameType
|
||||
*
|
||||
* @return Corresponding frame length
|
||||
* L2_FRAME_NONE_LEN if the frame type code cannot be recognized.
|
||||
*
|
||||
******************************************************************************/
|
||||
uint32_t L2_GetFrameLen(L2_FRAME_TYPE l2FrameType)
|
||||
{
|
||||
return Phy_GetFrameLen(L2_L2frame2L1frame(l2FrameType));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Convert L2 frame type to L1 frame type
|
||||
@@ -635,6 +427,12 @@ L1_FRAME_TYPE L2_L2frame2L1frame(L2_FRAME_TYPE l2Frame)
|
||||
return L1_NONE_FRAME;
|
||||
}
|
||||
}
|
||||
/** @} LinkLayer_Utility*/
|
||||
|
||||
/**
|
||||
* @defgroup LinkLayer_Main
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
@@ -1276,3 +1074,205 @@ int32_t Linklayer_Proc(L2_INST *instPtr)
|
||||
SysMonitor_UpdateLinklayerLog(&(instPtr->linkLog));
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Steer antenna beam to specified node.
|
||||
*
|
||||
* @param instPtr a pointer to link layer descriptor instance
|
||||
* @param nodeId destination node
|
||||
*
|
||||
* @return Corresponding frame length
|
||||
* L2_FRAME_NONE_LEN if the frame type code cannot be recognized.
|
||||
*
|
||||
******************************************************************************/
|
||||
int32_t L2_SteerBeam2Node(L2_INST *instPtr, uint8_t nodeId)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
int32_t Status;
|
||||
|
||||
COORD myPos, dstPos, beamDir;
|
||||
Status = L2_GetNodePos(instPtr->nodeList, nodeId, &dstPos);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Failed to retrieve position info of node %" PRIu8 ", remain last configuration.\n", nodeId);
|
||||
return EPARAM;
|
||||
}
|
||||
myPos.x = instPtr->sysInfo.posX;
|
||||
myPos.y = instPtr->sysInfo.posY;
|
||||
myPos.z = instPtr->sysInfo.posZ;
|
||||
|
||||
// TODO Check data format
|
||||
EULERANGLES attitudeEuler, antAttitudeEuler;
|
||||
attitudeEuler.alpha = DEG2RAD(instPtr->sysInfo.pitch);
|
||||
attitudeEuler.beta = DEG2RAD(instPtr->sysInfo.yaw);
|
||||
attitudeEuler.gamma = DEG2RAD(instPtr->sysInfo.roll);
|
||||
|
||||
// FIXME: confirm date source.
|
||||
antAttitudeEuler.alpha = DEG2RAD(0);
|
||||
antAttitudeEuler.beta = DEG2RAD(0);
|
||||
antAttitudeEuler.gamma = DEG2RAD(0);
|
||||
|
||||
// TODO Check data format
|
||||
QUATERNION attitude, antAttitude;
|
||||
attitude = Quaternion_FromeEulerAngles(attitudeEuler, EULERANGLES_XYZ);
|
||||
antAttitude = Quaternion_FromeEulerAngles(antAttitudeEuler, EULERANGLES_XYZ);
|
||||
|
||||
// --- --- Algorithm --- ---
|
||||
// TODO Check result validation
|
||||
// Compute beam direction vector
|
||||
beamDir = Coord_Sub(dstPos, myPos);
|
||||
|
||||
// Compute antenna attitude respect to ECEF
|
||||
antAttitude = Quaternion_Mult(attitude, antAttitude);
|
||||
|
||||
// Convert beam direction vector to antenna coordinate
|
||||
beamDir = Quaternion_Rotate(Quaternion_GeInverse(antAttitude), beamDir);
|
||||
// Normalize
|
||||
Coord_Normalize(&beamDir);
|
||||
|
||||
double oAxis, rAxis;
|
||||
oAxis = RAD2DEG(atan2(beamDir.z, beamDir.y));
|
||||
rAxis = RAD2DEG(acos(Coord_Dot(beamDir, COORD_X_AXIS)));
|
||||
Status = Phy_SetBeamAngle(instPtr->config.phyInstPtr, oAxis, rAxis);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Layer 2 setup next slot operation, update current operating frame.
|
||||
*
|
||||
* @param instPtr a pointer to linklayer instance
|
||||
* @param txrxMode tx/rx state for next slot
|
||||
* @param frameType frame type of next slot.
|
||||
*
|
||||
* @return Corresponding frame length
|
||||
* L2_FRAME_NONE_LEN if the frame type code cannot be recognized.
|
||||
*
|
||||
******************************************************************************/
|
||||
int32_t L2_SetupNextSlot(L2_INST *instPtr, L2_TOR_TYPE txrxMode, L2_FRAME_TYPE frameType)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
PHY_INST *phyRef = instPtr->config.phyInstPtr;
|
||||
int32_t Status;
|
||||
if (frameType < L2_SCAN_FRAME || frameType > L2_SVC_FRAME)
|
||||
{
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
// logging
|
||||
if (txrxMode == L2_TOR_TX)
|
||||
{
|
||||
instPtr->log.frameTx++;
|
||||
switch (frameType)
|
||||
{
|
||||
case L2_ADV_FRAME:
|
||||
instPtr->log.advTxCnt++;
|
||||
break;
|
||||
case L2_CFM_FRAME:
|
||||
instPtr->log.cfmTxCnt++;
|
||||
break;
|
||||
case L2_SVC_FRAME:
|
||||
instPtr->log.svcTxCnt++;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (txrxMode == L2_TOR_RX)
|
||||
{
|
||||
instPtr->log.frameRx++;
|
||||
switch (frameType)
|
||||
{
|
||||
case L2_ADV_FRAME:
|
||||
instPtr->log.advRxCnt++;
|
||||
break;
|
||||
case L2_CFM_FRAME:
|
||||
instPtr->log.cfmRxCnt++;
|
||||
break;
|
||||
case L2_SVC_FRAME:
|
||||
instPtr->log.svcRxCnt++;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if _DEBUG_LEVEL >= 3
|
||||
char *torStr = NULL;
|
||||
char *frameStr = NULL;
|
||||
switch (txrxMode)
|
||||
{
|
||||
case L2_TOR_SUSPEND:
|
||||
torStr = "SUSPEND";
|
||||
break;
|
||||
case L2_TOR_TX:
|
||||
torStr = "TX";
|
||||
break;
|
||||
case L2_TOR_RX:
|
||||
torStr = "RX";
|
||||
break;
|
||||
}
|
||||
switch (frameType)
|
||||
{
|
||||
case L2_SCAN_FRAME:
|
||||
frameStr = "Scan";
|
||||
break;
|
||||
case L2_ADV_FRAME:
|
||||
frameStr = "Advertisement";
|
||||
break;
|
||||
case L2_CFM_FRAME:
|
||||
frameStr = "Confirm";
|
||||
break;
|
||||
case L2_SVC_FRAME:
|
||||
frameStr = "Service";
|
||||
break;
|
||||
default:
|
||||
frameStr = "UNKNOWN Frame";
|
||||
break;
|
||||
}
|
||||
DBG_INFO("# Setup Next Slot # [%" PRIu32 "-%" PRIu32 "], %s, %s.\n",
|
||||
instPtr->frameNum.next,
|
||||
instPtr->slotNum.next,
|
||||
torStr, frameStr);
|
||||
#endif
|
||||
|
||||
// Update frame and tx/rx mode record.
|
||||
// Frame types shift (last <- curr <- next)
|
||||
L2_RcdShift(&(instPtr->frame), frameType);
|
||||
L2_RcdShift(&(instPtr->tor), txrxMode);
|
||||
|
||||
TIME_WORD pullTime = {0, 0};
|
||||
pullTime.int_part = TimeCtrl_GetIntCnt(instPtr->config.tmcInstPtr) + 1;
|
||||
Status = Phy_SetTimeWord(phyRef, &pullTime, PHY_TIME_WORD_POLL);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Physical set pull time failed, with error code: %" PRId32 "\n", Status);
|
||||
}
|
||||
|
||||
PHY_TOR_TYPE tor;
|
||||
switch (txrxMode)
|
||||
{
|
||||
case L2_TOR_SUSPEND:
|
||||
tor = PHY_TOR_SUSPEND;
|
||||
break;
|
||||
case L2_TOR_TX:
|
||||
tor = PHY_TOR_TX;
|
||||
break;
|
||||
case L2_TOR_RX:
|
||||
tor = PHY_TOR_RX;
|
||||
break;
|
||||
default:
|
||||
DBG_ERROR("Invalid txrx mode :%" PRId8 ".\n", txrxMode);
|
||||
return EPARAM;
|
||||
}
|
||||
|
||||
Status = Phy_SetupNextSlot(phyRef, tor, L2_L2frame2L1frame(frameType), instPtr->sendPktData);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Physical setup failed, with error code: %" PRId32 "\n", Status);
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
/** @} LinkLayer_Main*/
|
||||
/** @} LinkLayer*/
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: Header file for df linklayer functions
|
||||
* @file link_layer.h
|
||||
* @author FanHao ([email protected])
|
||||
* @brief DF Linklayer header file.
|
||||
* @version 0.1
|
||||
* @date 2023-05-06
|
||||
*
|
||||
* Date: 2021-11-13 13:33
|
||||
* LastEditTime: 2022-07-16 10:12
|
||||
* Revisions: Rev 0.1
|
||||
* History:
|
||||
* [2022-07-16]: New branch for DiJian.
|
||||
* [2021-11-23]: Initial version.
|
||||
*
|
||||
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @defgroup LinkLayer
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __LINK_LAYER_H_
|
||||
#define __LINK_LAYER_H_
|
||||
|
||||
@@ -30,81 +32,96 @@
|
||||
#define AssertL2Event(instPtr, event) Linklayer_EventHandler(instPtr, event)
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/**
|
||||
* @struct LinklayerConfig
|
||||
* @brief A struct holds all linklayer initialization parameters
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
L2_NODE_TYPE myType;
|
||||
bool isInterHead;
|
||||
uint8_t clustId;
|
||||
uint8_t myId;
|
||||
uint8_t headId;
|
||||
uint8_t bkpHeadId;
|
||||
uint8_t netScale;
|
||||
PHY_INST *phyInstPtr;
|
||||
TMC_INST *tmcInstPtr;
|
||||
L2_NODE_TYPE myType; ///< node type
|
||||
bool isInterHead; ///< indicate if node is head node
|
||||
uint8_t clustId; ///< node cluster id
|
||||
uint8_t myId; ///< node id
|
||||
uint8_t headId; ///< head node id
|
||||
uint8_t bkpHeadId; ///< backup head id
|
||||
uint8_t netScale; ///< net scale
|
||||
PHY_INST *phyInstPtr; ///< pointer to system physical layer instance
|
||||
TMC_INST *tmcInstPtr; ///< pointer to system timer controller layer instance
|
||||
} L2_CONFIG;
|
||||
|
||||
/**
|
||||
* @struct LinklayerLogLocal
|
||||
* @brief A struct holds linklayer operating log
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t frameRx;
|
||||
uint32_t frameTx;
|
||||
uint32_t frameRecv;
|
||||
uint32_t frameCorrect;
|
||||
uint32_t frameRx; ///< total rx frame count
|
||||
uint32_t frameTx; ///< total tx frame count
|
||||
uint32_t frameRecv; ///< total received frame count
|
||||
uint32_t frameCorrect; ///< total correctly received frame count
|
||||
|
||||
uint32_t advRxCnt;
|
||||
uint32_t advTxCnt;
|
||||
uint32_t advRecvCnt;
|
||||
uint32_t advCorrectCnt;
|
||||
uint32_t advRxCnt; ///< advertise rx frame count
|
||||
uint32_t advTxCnt; ///< advertise tx frame count
|
||||
uint32_t advRecvCnt; ///< advertise received frame count
|
||||
uint32_t advCorrectCnt; ///< advertise correctly received frame count
|
||||
|
||||
uint32_t cfmRxCnt;
|
||||
uint32_t cfmTxCnt;
|
||||
uint32_t cfmRecvCnt;
|
||||
uint32_t cfmCorrectCnt;
|
||||
uint32_t cfmRxCnt; ///< confirm rx frame count
|
||||
uint32_t cfmTxCnt; ///< confirm tx frame count
|
||||
uint32_t cfmRecvCnt; ///< confirm received frame count
|
||||
uint32_t cfmCorrectCnt; ///< confirm correctly received frame count
|
||||
|
||||
uint32_t svcRxCnt;
|
||||
uint32_t svcTxCnt;
|
||||
uint32_t svcRecvCnt;
|
||||
uint32_t svcCorrectCnt;
|
||||
uint32_t svcRxCnt; ///< service rx frame count
|
||||
uint32_t svcTxCnt; ///< service tx frame count
|
||||
uint32_t svcRecvCnt; ///< service received frame count
|
||||
uint32_t svcCorrectCnt; ///< service correctly received frame count
|
||||
|
||||
int64_t timeDev;
|
||||
uint8_t lastBeamWidth;
|
||||
uint32_t reconnectCnt;
|
||||
int64_t timeDev; ///< last time deviation estimation result
|
||||
uint8_t lastBeamWidth; ///< last beam width
|
||||
uint32_t reconnectCnt; ///< reconnect trial count
|
||||
|
||||
PAYLOAD rxLog;
|
||||
PAYLOAD txLog;
|
||||
} L2_LOG;
|
||||
|
||||
/**
|
||||
* @struct LinklayerInst
|
||||
* @brief A linklayer instance
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
L2_CONFIG config;
|
||||
L2_NODE_INFO myInfo;
|
||||
NODE_LIST *nodeList;
|
||||
L2_SCHD_POOL *schdEventPool;
|
||||
uint32_t netStartTime;
|
||||
bool isEnable; // if the node is connected to the network
|
||||
bool dataAvail; // if there is a valid received frame data in rx buffer
|
||||
bool cxn2Net; // if the node is connected to the network
|
||||
L2_RCD frameNum; // stores the last current and next frame number.
|
||||
L2_RCD slotNum; // stores the last current and next slot number.
|
||||
L2_RCD frame; // stores the last current and next link layer frame type.
|
||||
L2_RCD tor; // stores the last current and next link layer tx/rx state.
|
||||
L2_NODE_STATE mainState; // the main state of link layer state
|
||||
L2_NODE_STATE nextState; // next state of link layer state, which will be applied to mainState every second.
|
||||
L2_RTNE_CONFIG rtneConfig; // current routine table configuration and status.
|
||||
L2_SCAN_FSM *scanFSM; // FSM of scan net (link set up)
|
||||
L2_SVC_FSM *serviceFSM; // FSM of service net (data service)
|
||||
uint8_t *sendPktData;
|
||||
uint8_t *recvPktData;
|
||||
L2_LOG log;
|
||||
L2_CONFIG config; ///< linklayer configuration parameters
|
||||
L2_NODE_INFO myInfo; ///< current node info
|
||||
NODE_LIST *nodeList; ///< discovered node list
|
||||
L2_SCHD_POOL *schdEventPool; ///< event schedule pool
|
||||
uint32_t netStartTime; ///< network start time
|
||||
bool isEnable; ///< indicates if the node is connected to the network
|
||||
bool dataAvail; ///< indicates if there is a valid received frame data in rx buffer
|
||||
bool cxn2Net; ///< indicates if the node is connected to the network
|
||||
L2_RCD frameNum; ///< stores the last current and next frame number.
|
||||
L2_RCD slotNum; ///< stores the last current and next slot number.
|
||||
L2_RCD frame; ///< stores the last current and next link layer frame type.
|
||||
L2_RCD tor; ///< stores the last current and next link layer tx/rx state.
|
||||
L2_NODE_STATE mainState; ///< the main state of link layer state
|
||||
L2_NODE_STATE nextState; ///< next state of link layer state, which will be applied to mainState every second.
|
||||
L2_RTNE_CONFIG rtneConfig; ///< current routine table configuration and status.
|
||||
L2_SCAN_FSM *scanFSM; ///< FSM of scan net (link set up)
|
||||
L2_SVC_FSM *serviceFSM; ///< FSM of service net (data service)
|
||||
uint8_t *sendPktData; ///< send data buffer
|
||||
uint8_t *recvPktData; ///< received data buffer
|
||||
L2_LOG log; ///< Linklayer operating log
|
||||
// for system log
|
||||
SYSINFO sysInfo;
|
||||
LINKLOG linkLog;
|
||||
SYSINFO sysInfo; ///< system info
|
||||
LINKLOG linkLog; ///< linklayer log for system monitor
|
||||
} L2_INST;
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
extern L2_RTNE_TABLE_ENTRY *initTable[L2_INIT_RTNE_PERIOD];
|
||||
extern L2_RTNE_TABLE_ENTRY *normalTable[L2_NORMAL_RTNE_PERIOD];
|
||||
/************************** Function Prototypes ******************************/
|
||||
// Main
|
||||
/**
|
||||
* @defgroup LinkLayer_Main
|
||||
* @{
|
||||
*/
|
||||
int32_t Linklayer_Init(L2_INST **instPtr, const L2_CONFIG *config);
|
||||
int32_t Linklayer_Reconfig(L2_INST *instPtr, const L2_CONFIG *config);
|
||||
void Linklayer_Destroy(L2_INST *instPtr);
|
||||
@@ -115,24 +132,33 @@ int32_t Linklayer_EventHandler(L2_INST *instPtr, const L2_EVENT *l2Event);
|
||||
int32_t Linklayer_PktHandler(L2_INST *instPtr, L2_FRAME_TYPE frameType);
|
||||
int32_t L2_SteerBeam2Node(L2_INST *instPtr, uint8_t nodeId);
|
||||
int32_t L2_SetupNextSlot(L2_INST *instPtr, L2_TOR_TYPE txrxMode, L2_FRAME_TYPE frameType);
|
||||
void L2_FrameStateUpdate(L2_INST *instPtr);
|
||||
L2_FRAME_TYPE L2_GetLastOptFrameType(L2_INST *instPtr);
|
||||
L1_FRAME_TYPE L2_L2frame2L1frame(L2_FRAME_TYPE l2Frame);
|
||||
/** @} LinkLayer_Main*/
|
||||
|
||||
// Scheduling Event
|
||||
/**
|
||||
* @defgroup LinkLayer_Framing
|
||||
* @{
|
||||
*/
|
||||
void L2_FrameInsertChunk(uint8_t *frame, size_t offset, size_t bytes, const void *chunk);
|
||||
void L2_FrameGetChunk(uint8_t *frame, size_t offset, size_t bytes, void *chunk);
|
||||
int32_t L2_CrcAppend(uint8_t *dataBuff, uint32_t dataLen, uint32_t crcPos, L2_CRC_TYPE crcType);
|
||||
bool L2_CrcCheck(uint8_t *dataBuff, uint32_t dataLen, L2_CRC_TYPE crcType);
|
||||
/** @} LinkLayer_Framing*/
|
||||
|
||||
/**
|
||||
* @defgroup LinkLayer_Scheduler
|
||||
* @{
|
||||
*/
|
||||
void L2_EventPoolHandler(L2_INST *instPtr);
|
||||
int32_t L2_ScheduleEventAt(L2_INST *instPtr, L2_SCHD_EVENT *schdEvent, uint32_t frameNo, uint32_t slotNo);
|
||||
int32_t L2_ScheduleEventAfter(L2_INST *instPtr, L2_SCHD_EVENT *schdEvent, uint32_t numSlots);
|
||||
int32_t L2_RescheduleEventAt(L2_INST *instPtr, L2_SCHD_EVENT *schdEvent, uint32_t frameNo, uint32_t slotNo);
|
||||
int32_t L2_RescheduleEventAfter(L2_INST *instPtr, L2_SCHD_EVENT *schdEvent, uint32_t numSlots);
|
||||
/** @} LinkLayer_Scheduler*/
|
||||
|
||||
// Framing
|
||||
void L2_FrameInsertChunk(uint8_t *frame, size_t offset, size_t bytes, const void *chunk);
|
||||
void L2_FrameGetChunk(uint8_t *frame, size_t offset, size_t bytes, void *chunk);
|
||||
int32_t L2_CrcAppend(uint8_t *dataBuff, uint32_t dataLen, uint32_t crcPos, L2_CRC_TYPE crcType);
|
||||
bool L2_CrcCheck(uint8_t *dataBuff, uint32_t dataLen, L2_CRC_TYPE crcType);
|
||||
|
||||
// Scanning
|
||||
/**
|
||||
* @defgroup LinkLayer_Scan
|
||||
* @{
|
||||
*/
|
||||
int32_t L2_Scan_Init(L2_SCAN_FSM **scanFSMPtr);
|
||||
void L2_Scan_RefreashScanTable(L2_INST *instPtr);
|
||||
void L2_Scan_Reset(L2_SCAN_FSM *scanFSMPtr);
|
||||
@@ -140,16 +166,32 @@ void L2_Scan_Destroy(L2_SCAN_FSM *scanFSMPtr);
|
||||
int32_t L2_Scan_Proc(L2_INST *instPtr);
|
||||
int32_t L2_Scan_PktHandler(L2_INST *instPtr, uint8_t *msg);
|
||||
int32_t L2_Scan_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *schedEntry);
|
||||
/** @} LinkLayer_Scan*/
|
||||
|
||||
// Service
|
||||
/**
|
||||
* @defgroup LinkLayer_Service
|
||||
* @{
|
||||
*/
|
||||
int32_t L2_Service_Init(L2_SVC_FSM **svcFSMPtr);
|
||||
void L2_Service_Reset(L2_SVC_FSM *svcFSMPtr);
|
||||
void L2_Service_Destroy(L2_SVC_FSM *svcFSMPtr);
|
||||
int32_t L2_Service_PktHandler(L2_INST *instPtr, uint8_t *msg);
|
||||
int32_t L2_Service_Proc(L2_INST *instPtr);
|
||||
int32_t L2_Service_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *schedEntry);
|
||||
/** @} LinkLayer_Service*/
|
||||
|
||||
// Miscellaneous
|
||||
/**
|
||||
* @defgroup LinkLayer_TimeSync
|
||||
* @{
|
||||
*/
|
||||
int32_t L2_GetTimeDeviation(L2_INST *instPtr, uint32_t frameNum, uint32_t slotNum, bool relative, int64_t *timeDev);
|
||||
void L2_TimeAdjust(L2_INST *instPtr, const int64_t *timeDev);
|
||||
/** @} LinkLayer_TimeSync*/
|
||||
|
||||
/**
|
||||
* @defgroup LinkLayer_Utility
|
||||
* @{
|
||||
*/
|
||||
uint8_t L2_GetNodeId(L2_INST *instPtr);
|
||||
uint8_t L2_GetClusterId(L2_INST *instPtr);
|
||||
uint8_t L2_GetHeadId(L2_INST *instPtr);
|
||||
@@ -171,10 +213,10 @@ uint32_t L2_GetNextFrameNum(L2_INST *instPtr);
|
||||
uint32_t L2_GetNextSlotNum(L2_INST *instPtr);
|
||||
L2_FRAME_TYPE L2_GetNextFrameType(L2_INST *instPtr);
|
||||
L2_TOR_TYPE L2_GetNextTor(L2_INST *instPtr);
|
||||
|
||||
// Time syncronization
|
||||
int32_t L2_GetTimeDeviation(L2_INST *instPtr, uint32_t frameNum, uint32_t slotNum, bool relative, int64_t* timeDev);
|
||||
void L2_TimeAdjust(L2_INST *instPtr, const int64_t *timeDev);
|
||||
|
||||
L2_FRAME_TYPE L2_GetLastOptFrameType(L2_INST *instPtr);
|
||||
L1_FRAME_TYPE L2_L2frame2L1frame(L2_FRAME_TYPE l2Frame);
|
||||
/** @} LinkLayer_Utility*/
|
||||
|
||||
#endif /* __LINK_LAYER_H_ */
|
||||
|
||||
/** @} LinkLayer*/
|
||||
@@ -1,17 +1,19 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: A brief description of this file
|
||||
* @file link_layer_types.h
|
||||
* @author FanHao ([email protected])
|
||||
* @brief DF Linklayer types definition.
|
||||
* @version 0.1
|
||||
* @date 2023-05-06
|
||||
*
|
||||
* Date: 2022-08-28 22:53
|
||||
* LastEditTime: 2022-08-29 00:45
|
||||
* Revisions: Rev 0.0
|
||||
* History:
|
||||
* [2022-08-29]: Initial version.
|
||||
*
|
||||
* Copyright(c) 2022 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
/**
|
||||
* @defgroup LinkLayer
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __LINK_LAYER_DEF_H_
|
||||
#define __LINK_LAYER_DEF_H_
|
||||
@@ -26,6 +28,10 @@
|
||||
#include "../config/app_config.h"
|
||||
#endif
|
||||
/************************** Constant Definitions *****************************/
|
||||
/**
|
||||
* @name Linklayer_Common_Constants
|
||||
* @{
|
||||
*/
|
||||
// Common node ID definition
|
||||
#define L2_BROADCAST_ID 0xFF
|
||||
#define L2_NONE_ID 0
|
||||
@@ -48,9 +54,13 @@
|
||||
#define L2_NUM_SLOTS_10MS 2
|
||||
#define L2_NUM_SLOTS_5MS 1
|
||||
#define L2_NUM_SLOTS_SKIP 0
|
||||
/** @} Linklayer_Common_Constants*/
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/**
|
||||
* @struct LinklayerRecord
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t last;
|
||||
@@ -58,7 +68,8 @@ typedef struct
|
||||
uint32_t next;
|
||||
} L2_RCD;
|
||||
|
||||
/** @name Tx/Rx mode code
|
||||
/**
|
||||
* @enum LinklayerTorType
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
@@ -67,7 +78,8 @@ typedef enum
|
||||
L2_TOR_RX = 2
|
||||
} L2_TOR_TYPE;
|
||||
|
||||
/** @name Prior information type definition
|
||||
/**
|
||||
* @enum LinkLayerNodeType
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
@@ -77,7 +89,8 @@ typedef enum
|
||||
L2_NODE_BACKUP = 3
|
||||
} L2_NODE_TYPE;
|
||||
|
||||
/** @name Node state type definition
|
||||
/**
|
||||
* @enum LinklayerNodeState
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
@@ -89,23 +102,24 @@ typedef enum
|
||||
L2_SEEK_STATE = 5
|
||||
} L2_NODE_STATE;
|
||||
|
||||
/** @name Node information type definition
|
||||
* The following types define the detail node info which needed by the link layer.
|
||||
/**
|
||||
* @struct LinklayerNodeInfo
|
||||
* @brief Node information struct contains the detail node info which needed by the link layer.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t nodeId;
|
||||
uint8_t clustId;
|
||||
uint8_t headId;
|
||||
L2_NODE_TYPE nodeType;
|
||||
uint8_t beamNo;
|
||||
COORD pos;
|
||||
COORD speed;
|
||||
QUATERNION attitude;
|
||||
uint8_t nodeId; ///< node ID
|
||||
uint8_t clustId; ///< node cluster ID
|
||||
uint8_t headId; ///< cluster head ID
|
||||
L2_NODE_TYPE nodeType; ///< node type
|
||||
uint8_t beamNo; ///< beam number to this node
|
||||
COORD pos; ///< node position
|
||||
COORD speed; ///< node speed
|
||||
QUATERNION attitude; ///< node attitude
|
||||
} L2_NODE_INFO;
|
||||
|
||||
/** @name L2 event enum
|
||||
* A enum of L2 event types.
|
||||
/**
|
||||
* @enum LinklayerEvent
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
@@ -123,17 +137,17 @@ typedef enum
|
||||
L2_ROUTINE_UPDATE = 11
|
||||
} L2_EVENT_TYPE;
|
||||
|
||||
/** @name L2 event
|
||||
* A definition of L2 event instance.
|
||||
/**
|
||||
* @struct LinklayerEvent
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
L2_EVENT_TYPE event;
|
||||
void *msg;
|
||||
L2_EVENT_TYPE event; ///< event type
|
||||
void *msg; ///< event message
|
||||
} L2_EVENT;
|
||||
|
||||
/** @name Slot types
|
||||
* A definition of different slots.
|
||||
/**
|
||||
* @enum LinklayerSlotType
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
@@ -145,8 +159,8 @@ typedef enum
|
||||
L2_SLOT_SERVICE = 5,
|
||||
} L2_SLOT_TYPE;
|
||||
|
||||
/** @name Frame types
|
||||
* A definition of different frame types.
|
||||
/**
|
||||
* @enum LinklayerFrameType
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
@@ -157,8 +171,8 @@ typedef enum
|
||||
L2_SVC_FRAME = 4
|
||||
} L2_FRAME_TYPE;
|
||||
|
||||
/** @name Frame types
|
||||
* A definition of different frame types.
|
||||
/**
|
||||
* @enum LinklayerCRCType
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
@@ -168,17 +182,20 @@ typedef enum
|
||||
L2_CRC8_31 = 3
|
||||
} L2_CRC_TYPE;
|
||||
|
||||
/** @name Schedule subtable entry
|
||||
* A definition of Schedule subtable entry.
|
||||
/**
|
||||
* @struct LinklayerRoutineTableEntry
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
L2_SLOT_TYPE slotType : 8;
|
||||
uint8_t slotSeq;
|
||||
uint8_t src;
|
||||
uint8_t dst;
|
||||
L2_SLOT_TYPE slotType : 8; ///< slot type
|
||||
uint8_t slotSeq; ///< slot sequence number
|
||||
uint8_t src; ///< source node ID
|
||||
uint8_t dst; ///< destination node ID
|
||||
} L2_RTNE_TABLE_ENTRY;
|
||||
|
||||
/**
|
||||
* @enum LinklayerScanStage
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
L2_SCAN_NONE_STAGE = 0,
|
||||
@@ -187,46 +204,53 @@ typedef enum
|
||||
L2_SCAN_CFM_STAGE = 3
|
||||
} SCAN_STAGE;
|
||||
|
||||
/** @name Scan procedure FSM
|
||||
/**
|
||||
* @struct LinklayerScanFSM
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
bool isLocked; // init acq done.
|
||||
bool isAdvRecvd; // bm received.
|
||||
bool isAckPending; // 2way acq done.
|
||||
uint8_t scanCnt;
|
||||
uint8_t advTimeout;
|
||||
uint8_t cfmTimeout;
|
||||
SCAN_STAGE scanStage; // only for member node
|
||||
uint8_t beamNo;
|
||||
uint8_t tableNo;
|
||||
bool isLocked; ///< indicates if init acq done(beam locked).
|
||||
bool isAdvRecvd; ///< indicates if advertisement frame done(beam locked).
|
||||
bool isAckPending; ///< indicates if confirm message acked
|
||||
uint8_t scanCnt; ///< scan count
|
||||
uint8_t advTimeout; ///< adv receive try count
|
||||
uint8_t cfmTimeout; ///< cmf receive try count
|
||||
SCAN_STAGE scanStage; ///< scan stage \n
|
||||
/// only for member node
|
||||
uint8_t beamNo; ///< locked beam number
|
||||
uint8_t tableNo; ///< scan table index
|
||||
} L2_SCAN_FSM;
|
||||
|
||||
|
||||
/** @name Service procedure FSM
|
||||
/**
|
||||
* @struct LinklayerServiceFSM
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t txCnt;
|
||||
uint32_t rxCnt;
|
||||
uint32_t rxdCnt;
|
||||
uint32_t txCnt; ///< tx frame count
|
||||
uint32_t rxCnt; ///< rx frame count
|
||||
uint32_t rxdCnt; ///< received frame count
|
||||
#ifdef DATALINK_ENABLE_BERTEST
|
||||
uint32_t bitTotal;
|
||||
uint32_t bitError;
|
||||
double lossRate;
|
||||
double errorRate;
|
||||
uint32_t bitTotal; ///< received bits count
|
||||
uint32_t bitError; ///< error bits count
|
||||
double lossRate; ///< packet loss rate
|
||||
double errorRate; ///< bit error rate
|
||||
#endif
|
||||
} L2_SVC_FSM;
|
||||
|
||||
/**
|
||||
* @struct LinklayerRoutineConfig
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
L2_RTNE_TABLE_ENTRY **rtneTable;
|
||||
uint32_t rtnePrd;
|
||||
L2_RTNE_TABLE_ENTRY *last;
|
||||
L2_RTNE_TABLE_ENTRY *curr;
|
||||
L2_RTNE_TABLE_ENTRY *next;
|
||||
L2_RTNE_TABLE_ENTRY **rtneTable; ///< routine table
|
||||
uint32_t rtnePrd; ///< period of routine table
|
||||
L2_RTNE_TABLE_ENTRY *last; ///< last routine entry
|
||||
L2_RTNE_TABLE_ENTRY *curr; ///< curent routine entry
|
||||
L2_RTNE_TABLE_ENTRY *next; ///< next routine entry
|
||||
} L2_RTNE_CONFIG;
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
#endif /* __LINK_LAYER_DEF_H_ */
|
||||
|
||||
/** @} LinkLayer*/
|
||||
@@ -1,23 +1,31 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: Header of 814 linklayer messages
|
||||
* @file msg_def.c
|
||||
* @author FanHao ([email protected])
|
||||
* @brief DF Linklayer message definition constants.
|
||||
* @version 0.0
|
||||
* @date 2023-05-06
|
||||
*
|
||||
* Date: 2022-07-14 00:08
|
||||
* LastEditTime: 2022-07-14 22:52
|
||||
* Revisions: Rev 0.0
|
||||
* History:
|
||||
* [2022-07-14]: Initial version.
|
||||
*
|
||||
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayer
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @name LinkLayer_MSG_Constants
|
||||
* @{
|
||||
*/
|
||||
#ifndef __L2_MSG_DEF_H_
|
||||
#define __L2_MSG_DEF_H_
|
||||
|
||||
#define L2_PACK_LEN_MAX 512 // bytes
|
||||
|
||||
#define L2_ADV_PACK_LEN 28 // bytes
|
||||
#define L2_ADV_PACK_LEN 28 // bytes
|
||||
#define L2_CMF_PACK_LEN 268 // bytes
|
||||
#define L2_SVC_PACK_LEN 268 // bytes
|
||||
|
||||
@@ -115,5 +123,8 @@
|
||||
#define L2_MSG_SVC_CRC 266
|
||||
#define L2_MSG_SVC_CRC_LEN 2
|
||||
|
||||
|
||||
#endif //__L2_MSG_DEF_H_
|
||||
|
||||
/** @} LinkLayer_MSG_Constants*/
|
||||
|
||||
/** @} LinkLayer*/
|
||||
@@ -1,19 +1,25 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: Implementations of 814 linklayer local record.
|
||||
* @file node_list.c
|
||||
* @author FanHao ([email protected])
|
||||
* @brief DF Linklayer node list implementation file
|
||||
* @version 0.0
|
||||
* @date 2023-05-06
|
||||
*
|
||||
* Date: 2022-07-14 00:08
|
||||
* LastEditors: Fan Hao
|
||||
* LastEditTime: 2022-07-14 22:52
|
||||
* Revisions: Rev 0.0
|
||||
* History:
|
||||
* [2022-07-14]: Initial version.
|
||||
*
|
||||
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayer
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayer_NodeList
|
||||
* @{
|
||||
*/
|
||||
/***************************** Include Files *********************************/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -94,7 +100,7 @@ int32_t L2_NodeList_Init(NODE_LIST **list)
|
||||
* @brief Clear all nodes in the node list, free allocated memory.
|
||||
*
|
||||
* @param list
|
||||
*NONE
|
||||
* @return NONE
|
||||
*
|
||||
******************************************************************************/
|
||||
void L2_NodeList_Clear(NODE_LIST *list)
|
||||
@@ -123,7 +129,7 @@ void L2_NodeList_Destroy(NODE_LIST *list)
|
||||
* @param list
|
||||
* @param nodeId
|
||||
*
|
||||
* @return Node entry
|
||||
* @return Node entry \n
|
||||
* NULL if node dose not exist.
|
||||
*
|
||||
******************************************************************************/
|
||||
@@ -154,7 +160,7 @@ NODE_ENTRY *L2_GetNodeById(NODE_LIST *list, uint8_t nodeId)
|
||||
* @param nodeId
|
||||
* @param nodeType
|
||||
*
|
||||
* @return SUCCESS Node was added successfully.
|
||||
* @return SUCCESS Node was added successfully.\n
|
||||
* Other Error occurred.(Node already exist, memory alloc error ect.)
|
||||
*
|
||||
******************************************************************************/
|
||||
@@ -201,7 +207,7 @@ NODE_ENTRY *L2_AppendNode(NODE_LIST *list, uint8_t nodeId, L2_NODE_TYPE nodeType
|
||||
* @param list
|
||||
* @param nodeId
|
||||
*
|
||||
* @return SUCCESS Node has been successfully deleted.
|
||||
* @return SUCCESS Node has been successfully deleted.\n
|
||||
* Other Node not exist.
|
||||
*
|
||||
******************************************************************************/
|
||||
@@ -227,7 +233,7 @@ int32_t L2_DeleteNodeById(NODE_LIST *list, uint8_t nodeId)
|
||||
* @param list
|
||||
* @param nodeId
|
||||
*
|
||||
* @return true node in the list
|
||||
* @return true node in the list\n
|
||||
* false node not in the list
|
||||
*
|
||||
******************************************************************************/
|
||||
@@ -245,7 +251,7 @@ bool L2_isNodeInList(NODE_LIST *list, uint8_t nodeId)
|
||||
* @param nodeId
|
||||
* @param dst A pointer to store distance.
|
||||
*
|
||||
* @return SUCCESS distance has been successfully store in dst
|
||||
* @return SUCCESS distance has been successfully store in dst\n
|
||||
* FAILURE Node dose not exit.
|
||||
*
|
||||
******************************************************************************/
|
||||
@@ -273,7 +279,7 @@ int32_t L2_GetDistance(NODE_LIST *list, COORD myCoord, uint8_t nodeId, double *d
|
||||
* @param nodeId
|
||||
* @param newPos A structure stores the corresponding node position info.
|
||||
*
|
||||
* @return SUCCESS update successfully.
|
||||
* @return SUCCESS update successfully.\n
|
||||
* FAILURE node not exist.
|
||||
*
|
||||
******************************************************************************/
|
||||
@@ -300,7 +306,7 @@ int32_t L2_UpdateNodePos(NODE_LIST *list, uint8_t nodeId, const COORD *newPos)
|
||||
* @param nodeId
|
||||
* @param newPos A structure stores the corresponding node position info.
|
||||
*
|
||||
* @return SUCCESS update successfully.
|
||||
* @return SUCCESS update successfully.\n
|
||||
* FAILURE node not exist.
|
||||
*
|
||||
******************************************************************************/
|
||||
@@ -327,7 +333,7 @@ int32_t L2_GetNodePos(NODE_LIST *list, uint8_t nodeId, COORD *pos)
|
||||
* @param nodeId
|
||||
* @param newSpeed A structure stores the corresponding node speed info.
|
||||
*
|
||||
* @return SUCCESS update successfully.
|
||||
* @return SUCCESS update successfully.\n
|
||||
* FAILURE node not exist.
|
||||
*
|
||||
******************************************************************************/
|
||||
@@ -354,7 +360,7 @@ int32_t L2_UpdateNodeSpeed(NODE_LIST *list, uint8_t nodeId, const COORD *newSpee
|
||||
* @param nodeId
|
||||
* @param newSpeed A structure stores the corresponding node speed info.
|
||||
*
|
||||
* @return SUCCESS update successfully.
|
||||
* @return SUCCESS update successfully.\n
|
||||
* FAILURE node not exist.
|
||||
*
|
||||
******************************************************************************/
|
||||
@@ -380,7 +386,7 @@ int32_t L2_GetNodeSpeed(NODE_LIST *list, uint8_t nodeId, COORD *speed)
|
||||
* @param nodeId
|
||||
* @param devi
|
||||
*
|
||||
* @return SUCCESS update successfully.
|
||||
* @return SUCCESS update successfully.\n
|
||||
* FAILURE Node not exist.
|
||||
*
|
||||
******************************************************************************/
|
||||
@@ -432,7 +438,7 @@ int32_t L2_IncNodeTTL(NODE_LIST *list, uint8_t nodeId, uint32_t inc)
|
||||
* @param list
|
||||
* @param nodeId
|
||||
*
|
||||
* @return SUCCESS TTL has been successfully cleared.
|
||||
* @return SUCCESS TTL has been successfully cleared.\n
|
||||
* FAILURE Node not exist.
|
||||
*
|
||||
******************************************************************************/
|
||||
@@ -486,7 +492,7 @@ int32_t L2_GetNodeTTL(NODE_LIST *list, uint8_t nodeId, uint32_t *ttl)
|
||||
* @param operation A pointer to a function handled "NODE_ENTRY*" as input
|
||||
* which defines the operations need to be apply.
|
||||
*
|
||||
* @return SUCCESS Operations has been applied successfully to all nodes.
|
||||
* @return SUCCESS Operations has been applied successfully to all nodes.\n
|
||||
* Other Error occurred.
|
||||
*
|
||||
******************************************************************************/
|
||||
@@ -520,7 +526,7 @@ int32_t L2_IterEditNode(NODE_LIST *list, const void *param, int32_t (*operation)
|
||||
*
|
||||
* @param list
|
||||
* @param condition A pointer to a function handled "NODE_ENTRY*" as input
|
||||
* which defines the condition need to be verify.
|
||||
* which defines the condition need to be verify.
|
||||
*
|
||||
* @return SUCCESS
|
||||
*
|
||||
@@ -545,3 +551,7 @@ int32_t L2_IterDeleteNode(NODE_LIST *list, bool (*condition)(NODE_ENTRY *))
|
||||
clist_iterator_destroy(iter);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/** @} LinkLayer_NodeList*/
|
||||
|
||||
/** @} LinkLayer*/
|
||||
@@ -1,19 +1,27 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: Header of 814 linklayer local record.
|
||||
* @file node_list.h
|
||||
* @author FanHao ([email protected])
|
||||
* @brief DF Linklayer node list header file
|
||||
* @version 0.0
|
||||
* @date 2023-05-06
|
||||
*
|
||||
* Date: 2022-07-14 00:08
|
||||
* LastEditors: Fan Hao
|
||||
* LastEditTime: 2022-07-14 22:52
|
||||
* Revisions: Rev 0.0
|
||||
* History:
|
||||
* [2022-07-14]: Initial version.
|
||||
*
|
||||
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayer
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup LinkLayer_NodeList
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
#ifndef NODE_LIST_H_
|
||||
#define NODE_LIST_H_
|
||||
@@ -29,6 +37,9 @@
|
||||
/************************** Constant Definitions *****************************/
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
/**************************** Type Definitions *******************************/
|
||||
/**
|
||||
* @struct NodeList_Entry
|
||||
*/
|
||||
typedef struct NODE_LIST_ENTRY
|
||||
{
|
||||
L2_NODE_INFO nodeInfo;
|
||||
@@ -62,3 +73,6 @@ int32_t L2_IterEditNode(NODE_LIST *list, const void *param, int32_t (*operation)
|
||||
int32_t L2_IterDeleteNode(NODE_LIST *list, bool (*condition)(NODE_ENTRY *));
|
||||
|
||||
#endif /* NODE_LIST_H_ */
|
||||
|
||||
/** @} LinkLayer_NodeList*/
|
||||
/** @} LinkLayer*/
|
||||
@@ -1,17 +1,26 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: Time allocations for df datalink,
|
||||
* Date: 2022-07-16 17:05
|
||||
* LastEditTime: 2022-07-16 17:05
|
||||
* Revisions: Rev 0.1
|
||||
* History:
|
||||
* [2021-11-13]: Initial version.
|
||||
* @file routine_table.c
|
||||
* @author FanHao ([email protected])
|
||||
* @brief DF Linklayer node list implementation file
|
||||
* @version 0.0
|
||||
* @date 2023-05-06
|
||||
*
|
||||
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayer
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @name RoutineTable
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "link_layer.h"
|
||||
#include "link_layer_types.h"
|
||||
@@ -249,3 +258,6 @@ L2_RTNE_TABLE_ENTRY *normalTable[L2_NORMAL_RTNE_PERIOD] =
|
||||
{
|
||||
normalSub
|
||||
};
|
||||
|
||||
/** @} RoutineTable*/
|
||||
/** @} LinkLayer*/
|
||||
@@ -1,18 +1,24 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: Implementations of df linklayer scan net.
|
||||
* @file scan.c
|
||||
* @author FanHao ([email protected])
|
||||
* @brief DF Linklayer scan implementation file.
|
||||
* @version 0.1
|
||||
* @date 2023-05-06
|
||||
*
|
||||
* Date: 2021-11-10 19:04
|
||||
* LastEditTime: 2022-07-16 17:04
|
||||
* Revisions: Rev 0.1
|
||||
* History:
|
||||
* [2022-07-16]: New branch for DiJian.
|
||||
* [2021-11-10]: Initial version.
|
||||
*
|
||||
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
/**
|
||||
* @addtogroup LinkLayer
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayer_Scan
|
||||
* @{
|
||||
*/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
#include <string.h>
|
||||
@@ -893,3 +899,6 @@ int32_t L2_Scan_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntry)
|
||||
routine_err:
|
||||
return Status;
|
||||
}
|
||||
|
||||
/** @} LinkLayer_Scan*/
|
||||
/** @} LinkLayer*/
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: Event scheduling implementation
|
||||
* @file schdevent.c
|
||||
* @author FanHao ([email protected])
|
||||
* @brief DF Linklayer Event scheduling implementation file.
|
||||
* @version 0.1
|
||||
* @date 2023-05-06
|
||||
*
|
||||
* Date: 2023-12-21 13:32
|
||||
* LastEditors: Fan Hao
|
||||
* LastEditTime: 2023-12-21 13:32
|
||||
* Revisions: Rev 0.0
|
||||
* History:
|
||||
* [2023-12-21]: Initial version.
|
||||
*
|
||||
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
/**
|
||||
* @addtogroup LinkLayer
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayer_Scheduler
|
||||
* @{
|
||||
*/
|
||||
/***************************** Include Files *********************************/
|
||||
#include <stdlib.h>
|
||||
#include "schdevent.h"
|
||||
@@ -428,3 +433,6 @@ inline bool L2_isEventScheduled(const L2_SCHD_EVENT *schdEvent)
|
||||
ASSERT(schdEvent != NULL);
|
||||
return schdEvent->isSchd;
|
||||
}
|
||||
|
||||
/** @} LinkLayer_Scheduler*/
|
||||
/** @} LinkLayer*/
|
||||
@@ -1,18 +1,24 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: Event scheduling implementation
|
||||
* @file schdevent.c
|
||||
* @author FanHao ([email protected])
|
||||
* @brief DF Linklayer Event scheduling header file.
|
||||
* @version 0.1
|
||||
* @date 2023-05-06
|
||||
*
|
||||
* Date: 2023-12-21 13:32
|
||||
* LastEditors: Fan Hao
|
||||
* LastEditTime: 2023-12-21 13:32
|
||||
* Revisions: Rev 0.0
|
||||
* History:
|
||||
* [2023-12-21]: Initial version.
|
||||
*
|
||||
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
/**
|
||||
* @addtogroup LinkLayer
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayer_Scheduler
|
||||
* @{
|
||||
*/
|
||||
#ifndef SCHDEVENT_H_
|
||||
#define SCHDEVENT_H_
|
||||
|
||||
@@ -24,8 +30,8 @@
|
||||
#include "clist.h"
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
/**************************** Type Definitions *******************************/
|
||||
/** @name L2 event
|
||||
* A definition of L2 event instance.
|
||||
/**
|
||||
* @struct LinklayerEvent
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
@@ -38,8 +44,8 @@ typedef struct
|
||||
uint32_t schdSlot;
|
||||
} L2_SCHD_EVENT;
|
||||
|
||||
/** @name L2 event
|
||||
* A definition of L2 event instance.
|
||||
/**
|
||||
* @struct L2 event
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
@@ -63,3 +69,6 @@ bool L2_isEventScheduled(const L2_SCHD_EVENT *schdEvent);
|
||||
int32_t L2_CancelEvent(L2_SCHD_EVENT *schdEvent);
|
||||
|
||||
#endif // SCHDEVENT_H_
|
||||
|
||||
/** @} LinkLayer_Scheduler*/
|
||||
/** @} LinkLayer*/
|
||||
@@ -1,18 +1,24 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: Implementations for df datalink service net.
|
||||
* Date: 2021-11-16 00:08
|
||||
* LastEditTime: 2022-07-16 17:04
|
||||
* Revisions: Rev 0.1
|
||||
* History:
|
||||
* [2022-07-16]: New branch for DiJian.
|
||||
* [2021-11-16]: Initial version.
|
||||
* @file service.c
|
||||
* @author FanHao ([email protected])
|
||||
* @brief DF Linklayer service implementation file.
|
||||
* @version 0.0
|
||||
* @date 2023-05-06
|
||||
*
|
||||
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
/**
|
||||
* @addtogroup LinkLayer
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayer_Service
|
||||
* @{
|
||||
*/
|
||||
/***************************** Include Files *********************************/
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
@@ -427,3 +433,6 @@ int32_t L2_Service_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntr
|
||||
#endif
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/** @} LinkLayer_Service*/
|
||||
/** @} LinkLayer*/
|
||||
@@ -1,21 +1,24 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: Time sync implementation file.
|
||||
* @file time_sync.c
|
||||
* @author FanHao ([email protected])
|
||||
* @brief DF Linklayer time sync implementation file.
|
||||
* @version 0.0
|
||||
* @date 2023-05-06
|
||||
*
|
||||
* Author: Author's name
|
||||
* Date: 2021-12-04 16:32
|
||||
* LastEditors: FanHao
|
||||
* LastEditTime: 2022-07-10 20:43
|
||||
* Revisions: Rev 0.0
|
||||
* History:
|
||||
* [2022-07-10]: New branch for Dijian.
|
||||
* [2021-12-04]: Initial version.
|
||||
*
|
||||
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
/**
|
||||
* @addtogroup LinkLayer
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup LinkLayer_TimeSync
|
||||
* @{
|
||||
*/
|
||||
/***************************** Include Files *********************************/
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
@@ -96,3 +99,7 @@ void L2_TimeAdjust(L2_INST *instPtr, const int64_t *timeDev)
|
||||
slotTimerAdjmet.frac_part = (uint32_t)(*timeDev % TIME_FRAC_MAX);
|
||||
TimeCtrl_TimeAdjust(instPtr->config.tmcInstPtr, &slotTimerAdjmet, TM_ADJ_ADD);
|
||||
}
|
||||
|
||||
/** @} LinkLayer_TimeSync*/
|
||||
|
||||
/** @} LinkLayer*/
|
||||
@@ -15,12 +15,26 @@
|
||||
* Lab of Communication and Networking
|
||||
*
|
||||
******************************************************************************/
|
||||
/**
|
||||
* @addtogroup PhysicalLayer
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup PhysicalLayer_AntennaControl
|
||||
* @{
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
#include "error.h"
|
||||
#include "phy_layer.h"
|
||||
|
||||
/**
|
||||
* @name PhysicalLayer_AntennaConfig_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define ANT_PI 3.14159265358979323846
|
||||
|
||||
#define ANT_COINFO_HEAD 0xAA
|
||||
@@ -54,6 +68,7 @@
|
||||
#define CALIBRMODE_SINGLE_TR_CAL 0x01
|
||||
|
||||
#define RF_CTRL_DEFAULT 0x00
|
||||
/** @} PhysicalLayer_AntennaConfig_Constants*/
|
||||
|
||||
// Pair by regex
|
||||
// Regex: (([0-9]+, ){8})
|
||||
@@ -133,6 +148,7 @@ uint16_t hopPattern_1M2BPS_5MS[L1_FRAME_1M2BPS_5MS_HOPS] =
|
||||
900, 1000, 500, 500
|
||||
};
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Initialize antenna configurations (load preset values)
|
||||
@@ -367,3 +383,7 @@ int32_t Phy_SetBeamAngle(PHY_INST *instPtr, double offAx, double rndAx)
|
||||
instPtr->antConfig.raxis[1] = (uint8_t)rndAxDeg;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/** @} PhysicalLayer_AntennaControl*/
|
||||
|
||||
/** @} PhysicalLayer*/
|
||||
@@ -1,26 +1,20 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: Implementation of physical control functions
|
||||
* @file phy_layer.h
|
||||
* @author FanHao ([email protected])
|
||||
* @brief Physical layer control implementation file.
|
||||
* @version 0.0
|
||||
* @date 2023-04-24
|
||||
*
|
||||
* Date: 2021-11-16 00:08
|
||||
* LastEditTime: 2024-01-20 17:48
|
||||
* Revisions: Rev 0.2
|
||||
* History:
|
||||
* [2021-11-16]: Initial version.
|
||||
* [2022-06-18]: New branch for glink control purpose:
|
||||
* -Add poll mode, physical layer will start Tx/Rx procedure
|
||||
* at specific time stamp.
|
||||
* -Add 61/37 beam switch
|
||||
* -Code simplification.
|
||||
* [2023-04-24]: Feature add:
|
||||
* - Read frame type from PL status register.
|
||||
* [2024-01-20]: Porting for DUIFEI.
|
||||
*
|
||||
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup PhysicalLayer
|
||||
* @{
|
||||
*/
|
||||
/***************************** Include Files *********************************/
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
@@ -35,6 +29,10 @@
|
||||
#endif
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
/**
|
||||
* @name PhysicalLayer_Private_Constants
|
||||
* @{
|
||||
*/
|
||||
#define PHY_TIME_WORD_H_MAX UINT32_MAX
|
||||
#define PHY_TIME_WORD_L_MAX 0x0007A120 // 5ms/10ns
|
||||
|
||||
@@ -71,6 +69,7 @@
|
||||
#define ATTN_40KBPS_20MS 21
|
||||
#define ATTN_200KBPS_5MS ATTN_DEFAULT
|
||||
#define ATTN_1M2BPS_5MS ATTN_DEFAULT
|
||||
/** @} PhysicalLayer_Private_Constants*/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
/************************** Function Prototypes ******************************/
|
||||
@@ -1358,3 +1357,5 @@ void Phy_RefreshHwSate(PHY_INST *instPtr)
|
||||
|
||||
SysMonitor_UpdateHardwareStatus(&(instPtr->hwSate));
|
||||
}
|
||||
|
||||
/** @} PhysicalLayer*/
|
||||
@@ -1,26 +1,21 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: Physical layer control definitions and function prototypes.
|
||||
* @file phy_layer.c
|
||||
* @author FanHao ([email protected])
|
||||
* @brief Physical layer control header file.
|
||||
* @version 0.0
|
||||
* @date 2023-04-24
|
||||
*
|
||||
* Date: 2021-12-04 16:32
|
||||
* LastEditTime: 2024-01-20 17:41
|
||||
* Revisions: Rev 0.1
|
||||
* History:
|
||||
* [2021-12-08]: Initial version.
|
||||
* [2022-06-18]: New branch for glink control purpose:
|
||||
* -Add poll mode, physical layer will start Tx/Rx procedure
|
||||
* at specific time stamp.
|
||||
* -Add 61/37 beam switch
|
||||
* -Code simplification.
|
||||
* [2023-04-24]: Feature add:
|
||||
* - Read frame type from PL status register.
|
||||
* [2024-01-20]: New branch for DUIFEI.
|
||||
*
|
||||
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @defgroup PhysicalLayer
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef PHY_CTRL_H_
|
||||
#define PHY_CTRL_H_
|
||||
|
||||
@@ -35,13 +30,17 @@
|
||||
#include "../../system_monitor.h"
|
||||
#include "../../time_ctrl/time_ctrl.h"
|
||||
/************************** Constant Definitions *****************************/
|
||||
/**
|
||||
* @name PhysicalLayer_Common_Constant
|
||||
* @{
|
||||
*/
|
||||
#define L1_NUM_ANT_NRRW_PATTERN 37
|
||||
#define L1_INIT_BEAM_NO 0
|
||||
#define L1_INIT_ANT_WD PHY_ANT_BEAM_120
|
||||
#define L1_INIT_ANT_NO 0
|
||||
|
||||
#define L1_FRAME_NONE_LEN UINT32_MAX // byte
|
||||
#define L1_FRAME_NONE_COMP UINT32_MAX // *10ns(Timer_L)
|
||||
#define L1_FRAME_NONE_LEN UINT32_MAX // byte
|
||||
#define L1_FRAME_NONE_COMP UINT32_MAX // *10ns(Timer_L)
|
||||
#define L1_FRAME_NONE_HOPS UINT32_MAX
|
||||
#define L1_FRAME_MAX_HOPS 81
|
||||
#define L1_FRAME_2KBPS_20MS_HOPS 1
|
||||
@@ -52,10 +51,13 @@
|
||||
#define L1_FRAME_40KBPS_10MS_HOPS 9
|
||||
#define L1_FRAME_200KBPS_5MS_HOPS 20
|
||||
#define L1_FRAME_1M2BPS_5MS_HOPS 20
|
||||
|
||||
#define PHY_LOG_EXPIRE 40 // 50*5ms
|
||||
#define PHY_LOG_EXPIRE 40 // 50*5ms
|
||||
/** @} */
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
/**************************** Type Definitions *******************************/
|
||||
/**
|
||||
* @enum PhysicalLayerFrameType
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
L1_NONE_FRAME = 0,
|
||||
@@ -69,71 +71,61 @@ typedef enum
|
||||
L1_1M2BPS_5MS_FRAME = 8
|
||||
} L1_FRAME_TYPE;
|
||||
|
||||
/**
|
||||
* @struct PhysicalLayerAntennaConfig
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/*** Ant Control ***/
|
||||
/* Antenna control frame head 0xAA */
|
||||
/* default 0, reserved for further use */
|
||||
uint8_t ctrlWord;
|
||||
/* high 4 bits specified beam mode.
|
||||
* low 4 bits specified power control */
|
||||
uint8_t antMode;
|
||||
/* off-axis angle range is 0~60,
|
||||
* 0.1 degree each LSB */
|
||||
uint8_t oaxis[2];
|
||||
/* round-axis angle range is 0~360,
|
||||
* 0.1 degree each LSB */
|
||||
uint8_t raxis[2];
|
||||
/* 0~3500Mhz, step 1MHz */
|
||||
uint8_t antFreq[2];
|
||||
/* in single tr mode, 0~63 specified tr channel
|
||||
* in single subarray mode, 0~3 specified the subarray
|
||||
* Only in debug mode*/
|
||||
uint8_t trSlect;
|
||||
/* Antenna attenuation 0~31, 0.5dB each LSB, Only in debug mode */
|
||||
uint8_t antAtt;
|
||||
/* 0~63, 5.625 degree each LSB, Only in debug mode*/
|
||||
uint8_t phase;
|
||||
/* Only for debug */
|
||||
/* default 0x00 */
|
||||
uint8_t rxtxMode;
|
||||
/* 0x00 Normal, 0x01 single tr calibration */
|
||||
uint8_t calibrMode;
|
||||
/* reserved for further use */
|
||||
uint8_t antReserved;
|
||||
uint8_t ctrlWord; ///< Antenna control frame head 0xAA\n
|
||||
/// default 0, reserved for further use
|
||||
uint8_t antMode; ///< high 4 bits specified beam mode.\n
|
||||
/// low 4 bits specified power control
|
||||
uint8_t oaxis[2]; ///< off-axis angle range is 0~60 \n
|
||||
/// 0.1 degree each LSB
|
||||
uint8_t raxis[2]; ///< round-axis angle range is 0~360, \n
|
||||
/// 0.1 degree each LSB
|
||||
uint8_t antFreq[2]; ///< 0~3500Mhz, step 1MHz
|
||||
uint8_t trSlect; ///< in single tr mode, 0~63 specified tr channel \n
|
||||
/// in single subarray mode, 0~3 specified the subarray
|
||||
/// ! Only in debug mode!
|
||||
uint8_t antAtt; ///< Antenna attenuation 0~31, 0.5dB each LSB, Only in debug mode
|
||||
uint8_t phase; ///< 0~63, 5.625 degree each LSB, Only in debug mode
|
||||
uint8_t rxtxMode; ///< Only for debug \n
|
||||
/// default 0x00
|
||||
uint8_t calibrMode; ///< 0x00 Normal, 0x01 single tr calibration
|
||||
uint8_t antReserved; ///< reserved for further use
|
||||
|
||||
/*** RF Control ***/
|
||||
/* [7:4]RF enable: 0-On, 1-Off(Default); [3:0]Work mode: 0(default) */
|
||||
uint8_t rfCtrl;
|
||||
/* 0~3500Mhz, step 1MHz */
|
||||
uint8_t rfFreq[2];
|
||||
/* RF MGC control: 0~31, 1dB each LSB*/
|
||||
uint8_t rfTxMgc;
|
||||
/* RF channel 1&2 calibration mgc: [7:4] Channle1 - max 15db, 1dB each LSB
|
||||
* [3:0] Channle2 - max 15db, 1dB each LSB*/
|
||||
uint8_t rf12CalMgc;
|
||||
/* RF channel 3&4 calibration mgc: [7:4] Channle3 - max 15db, 1dB each LSB
|
||||
* [3:0] Channle4 - max 15db, 1dB each LSB*/
|
||||
uint8_t rf34CalMgc;
|
||||
/* Receive channel 1-4 MGC: 0~31, 1dB each LSB */
|
||||
uint8_t rcvMgc;
|
||||
/* Receive monitor, 0-normal, 1-switch to monitor port */
|
||||
uint8_t rfMonitor;
|
||||
/* reserved for further use */
|
||||
uint8_t rfReserved0;
|
||||
uint8_t rfReserved1;
|
||||
uint8_t rfCtrl; ///< [7:4]RF enable: 0-On, 1-Off(Default); [3:0]Work mode: 0(default)
|
||||
uint8_t rfFreq[2]; ///< 0~3500Mhz, step 1MHz
|
||||
uint8_t rfTxMgc; ///< RF MGC control: 0~31, 1dB each LSB
|
||||
uint8_t rf12CalMgc; ///< RF channel 1&2 calibration mgc\n
|
||||
/// [7:4] Channle1 - max 15db, 1dB each LSB \n
|
||||
/// [3:0] Channle2 - max 15db, 1dB each LSB
|
||||
uint8_t rf34CalMgc; ///< RF channel 3&4 calibration mgc\n
|
||||
/// [7:4] Channle3 - max 15db, 1dB each LSB
|
||||
/// [3:0] Channle4 - max 15db, 1dB each LSB
|
||||
uint8_t rcvMgc; ///< Receive channel 1-4 MGC: 0~31, 1dB each LSB
|
||||
uint8_t rfMonitor; ///< Receive monitor, 0-normal, 1-switch to monitor port
|
||||
uint8_t rfReserved0; ///< reserved for further use
|
||||
uint8_t rfReserved1; ///< reserved for further use
|
||||
} PHY_ANT_CONFIG;
|
||||
|
||||
/**
|
||||
* @struct PhysicalLayerAntennaAngle
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/* off-axis angle range is 0~60,
|
||||
* 0.1 degree each LSB */
|
||||
uint16_t oaxis;
|
||||
/* round-axis angle range is 0~360,
|
||||
* 0.1 degree each LSB */
|
||||
uint16_t raxis;
|
||||
uint16_t oaxis; ///< off-axis angle range is 0~60
|
||||
/// 0.1 degree each LSB
|
||||
uint16_t raxis; ///< round-axis angle range is 0~360
|
||||
/// 0.1 degree each LSB
|
||||
} PHY_ANT_ANGLE;
|
||||
|
||||
/**
|
||||
* @enum PhysicalLayerTimeWordType
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PHY_TIME_WORD_NONE = 0,
|
||||
@@ -141,6 +133,9 @@ typedef enum
|
||||
PHY_TIME_WORD_LISTEN_TIMEOUT = 2
|
||||
} PHY_TIME_WORD_TYPE;
|
||||
|
||||
/**
|
||||
* @enum PhysicalLayerAntennaBeamWidth
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PHY_ANT_BEAM_NONE = 0,
|
||||
@@ -150,6 +145,9 @@ typedef enum
|
||||
PHY_ANT_BEAM_16 = 4
|
||||
} PHY_ANT_BEAM_WIDTH;
|
||||
|
||||
/**
|
||||
* @enum PhysicalLayerTorState
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PHY_TOR_SUSPEND = 0,
|
||||
@@ -157,6 +155,9 @@ typedef enum
|
||||
PHY_TOR_RX = 2
|
||||
} PHY_TOR_TYPE;
|
||||
|
||||
/**
|
||||
* @enum PhysicalLayerWorkMode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PHY_MODE_NONE = 0,
|
||||
@@ -165,6 +166,9 @@ typedef enum
|
||||
PHY_MODE_PULL = 3
|
||||
} PHY_MODE;
|
||||
|
||||
/**
|
||||
* @enum PhysicalLayerAntennaMode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PHY_ANT_MODE_NONE = 0,
|
||||
@@ -173,23 +177,9 @@ typedef enum
|
||||
PHY_ANT_MODE_POWER_FULL = 3,
|
||||
} PHY_ANT_MODE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t devId;
|
||||
uint32_t txBramId;
|
||||
uint32_t rxBramId;
|
||||
uint32_t antBramId;
|
||||
uint32_t antInfoBramId;
|
||||
uint32_t hwXadcId;
|
||||
uintptr_t baseAddr;
|
||||
#ifndef EMULATION
|
||||
uint8_t (*get_clk_state)(void);
|
||||
uint8_t (*get_ad_lock_state)(void);
|
||||
int8_t (*get_ad0_temp)(void);
|
||||
int8_t (*get_ad1_temp)(void);
|
||||
#endif
|
||||
} PHY_CONFIG;
|
||||
|
||||
/**
|
||||
* @struct PhysicalLayerRecord
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int32_t last;
|
||||
@@ -197,36 +187,61 @@ typedef struct
|
||||
int32_t next;
|
||||
} PHY_RCD;
|
||||
|
||||
/**
|
||||
* @struct PhysicalLayerConfig
|
||||
* @brief struct holds all physical layer initialization parameters
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
PHY_CONFIG phyCofig; // Device address configs
|
||||
uintptr_t recvDataAddr;
|
||||
uintptr_t sendDataAddr;
|
||||
uintptr_t antConfigAddr;
|
||||
uintptr_t antInfoAddr;
|
||||
bool isPhyEn; // if physical layer running
|
||||
bool isAcq; // if last reception acquisition success
|
||||
bool isFrameSync; // if last reception frame sync success
|
||||
bool isDecode; // if last reception decode success
|
||||
bool isValid; // if last reception frame data valid (crc check pass)
|
||||
bool isPresetHop; // if using preset frequency hop
|
||||
TIME_WORD recvSlotTime; // last slot start time stamp
|
||||
TIME_WORD recvFsTime; // last frame sync time stamp
|
||||
PHY_RCD antNo; // antenna number record
|
||||
PHY_RCD beamNo; // beam number record
|
||||
PHY_RCD beamWd; // beam width record
|
||||
PHY_RCD tor; // tx rx state record
|
||||
PHY_RCD frameType; // frame type record
|
||||
uint32_t sendDataOffset; // antenna configuration bram offset (to implement ping-pong data flow)
|
||||
uint32_t antConfigOffset; // antenna configuration bram offset (to implement ping-pong data flow)
|
||||
PHY_ANT_CONFIG antConfig; // antenna configuration pointer
|
||||
uint32_t devId; ///< device ID
|
||||
uint32_t txBramId; ///< tx bram ID
|
||||
uint32_t rxBramId; ///< rx bram ID
|
||||
uint32_t antBramId; ///< antenna config bram ID
|
||||
uint32_t antInfoBramId; ///< antenna beam info bram ID
|
||||
uint32_t hwXadcId; ///< hardware xadc device ID
|
||||
uintptr_t baseAddr; ///< Physical layer controller base address
|
||||
#ifndef EMULATION
|
||||
XAdcPs hwXadc;
|
||||
uint8_t (*get_clk_state)(void); ///< function handle returns hardware clock state
|
||||
uint8_t (*get_ad_lock_state)(void); ///< function handle returns adc lock state
|
||||
int8_t (*get_ad0_temp)(void); ///< function handle returns adc0 temperature state
|
||||
int8_t (*get_ad1_temp)(void); ///< function handle returns adc1 temperature state
|
||||
#endif
|
||||
PHY_ANT_ANGLE antNrrwPattern[L1_NUM_ANT_NRRW_PATTERN];
|
||||
HWSTATE hwSate;
|
||||
PHYLOG phyLog;
|
||||
uint32_t lastLogTime;
|
||||
} PHY_CONFIG;
|
||||
|
||||
/**
|
||||
* @struct PhysicalLayerInst
|
||||
* @brief Physical Layer operating instance
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
PHY_CONFIG phyCofig; ///< physical layer configuration parameters
|
||||
uintptr_t recvDataAddr; ///< receive data bram address
|
||||
uintptr_t sendDataAddr; ///< send data bram address
|
||||
uintptr_t antConfigAddr; ///< antenna config data bram address
|
||||
uintptr_t antInfoAddr; ///< antenna beam info data bram address
|
||||
bool isPhyEn; ///< indicates if physical layer running
|
||||
bool isAcq; ///< indicates if last reception acquisition success
|
||||
bool isFrameSync; ///< indicates if last reception frame sync success
|
||||
bool isDecode; ///< indicates if last reception decode success
|
||||
bool isValid; ///< indicates if last reception frame data valid (crc check pass)
|
||||
bool isPresetHop; ///< indicates if using preset frequency hop
|
||||
TIME_WORD recvSlotTime; ///< last slot start time stamp
|
||||
TIME_WORD recvFsTime; ///< last frame sync time stamp
|
||||
PHY_RCD antNo; ///< antenna number record
|
||||
PHY_RCD beamNo; ///< beam number record
|
||||
PHY_RCD beamWd; ///< beam width record
|
||||
PHY_RCD tor; ///< tx rx state record
|
||||
PHY_RCD frameType; ///< frame type record
|
||||
uint32_t sendDataOffset; ///< antenna configuration bram offset (to implement ping-pong data flow)
|
||||
uint32_t antConfigOffset; ///< antenna configuration bram offset (to implement ping-pong data flow)
|
||||
PHY_ANT_CONFIG antConfig; ///< antenna configuration pointer
|
||||
#ifndef EMULATION
|
||||
XAdcPs hwXadc; ///< hardware Xadc instance
|
||||
#endif
|
||||
PHY_ANT_ANGLE antNrrwPattern[L1_NUM_ANT_NRRW_PATTERN]; ///< antenna beam scan pattern
|
||||
HWSTATE hwSate; ///< hardware state log
|
||||
PHYLOG phyLog; ///< physical state log
|
||||
uint32_t lastLogTime; /// physical state log time stamp
|
||||
} PHY_INST;
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
@@ -237,7 +252,6 @@ extern uint16_t hopPattern_10KBPS_10MS[L1_FRAME_10KBPS_10MS_HOPS];
|
||||
extern uint16_t hopPattern_10KBPS_20MS[L1_FRAME_10KBPS_20MS_HOPS];
|
||||
extern uint16_t hopPattern_40KBPS_10MS[L1_FRAME_40KBPS_10MS_HOPS];
|
||||
extern uint16_t hopPattern_40KBPS_20MS[L1_FRAME_40KBPS_20MS_HOPS];
|
||||
|
||||
extern uint16_t hopPattern_200KBPS_5MS[L1_FRAME_200KBPS_5MS_HOPS];
|
||||
extern uint16_t hopPattern_1M2BPS_5MS[L1_FRAME_1M2BPS_5MS_HOPS];
|
||||
|
||||
@@ -269,14 +283,6 @@ int32_t Phy_SetHopPattern(void *patternBuff, uint32_t patternLen);
|
||||
uint32_t Phy_GetHopLength(L1_FRAME_TYPE frameType);
|
||||
uint32_t Phy_GetTimeComp(L1_FRAME_TYPE frameType);
|
||||
|
||||
void Phy_AntConfigInit(PHY_ANT_CONFIG *antConfig);
|
||||
void Phy_AntConfigMode(PHY_INST *instPtr, PHY_ANT_MODE mode);
|
||||
void Phy_SetBeamTable(PHY_INST *instPtr, PHY_ANT_ANGLE *table, uint32_t offset);
|
||||
int32_t Phy_SetBeamWidth(PHY_INST *instPtr, PHY_ANT_BEAM_WIDTH beamWidth);
|
||||
int32_t Phy_SetBeamNo(PHY_INST *instPtr, int32_t beamNo, PHY_ANT_BEAM_WIDTH beamWidth);
|
||||
int32_t Phy_SetBeamAngle(PHY_INST *phyInstPtr, double offAx, double rndAx);
|
||||
int32_t Phy_SetTimeWord(PHY_INST *instPtr, const TIME_WORD *tmWord, PHY_TIME_WORD_TYPE tmType);
|
||||
|
||||
uint8_t Phy_LastScanBeamNo(PHY_INST *instPtr);
|
||||
double Phy_GetFreqEst(PHY_INST *instPtr);
|
||||
double Phy_GetCoarseFreqEst(PHY_INST *instPtr);
|
||||
@@ -285,4 +291,19 @@ void Phy_GetFrameSyncTimeStamp(PHY_INST *instPtr, TIME_WORD *frameSyncT);
|
||||
void Phy_GetLastReceivedFrameSyncTimeStamp(PHY_INST *instPtr, TIME_WORD *frameSyncT);
|
||||
void Phy_GetSlotStartTimeStamp(PHY_INST *instPtr, TIME_WORD *slotStart);
|
||||
void Phy_GetLastReceivedSlotStartTimeStamp(PHY_INST *instPtr, TIME_WORD *slotStart);
|
||||
|
||||
/**
|
||||
* @defgroup PhysicalLayer_AntennaControl
|
||||
* @{
|
||||
*/
|
||||
void Phy_AntConfigInit(PHY_ANT_CONFIG *antConfig);
|
||||
void Phy_AntConfigMode(PHY_INST *instPtr, PHY_ANT_MODE mode);
|
||||
void Phy_SetBeamTable(PHY_INST *instPtr, PHY_ANT_ANGLE *table, uint32_t offset);
|
||||
int32_t Phy_SetBeamWidth(PHY_INST *instPtr, PHY_ANT_BEAM_WIDTH beamWidth);
|
||||
int32_t Phy_SetBeamNo(PHY_INST *instPtr, int32_t beamNo, PHY_ANT_BEAM_WIDTH beamWidth);
|
||||
int32_t Phy_SetBeamAngle(PHY_INST *phyInstPtr, double offAx, double rndAx);
|
||||
int32_t Phy_SetTimeWord(PHY_INST *instPtr, const TIME_WORD *tmWord, PHY_TIME_WORD_TYPE tmType);
|
||||
/** @} PhysicalLayer_AntennaControl*/
|
||||
#endif // PHY_CTRL_H_
|
||||
|
||||
/** @} PhysicalLayer*/
|
||||
@@ -1,24 +1,24 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: Physical layer register definitions
|
||||
* @file phy_layer.h
|
||||
* @author FanHao ([email protected])
|
||||
* @brief Physical layer controller register definition
|
||||
* @version 0.0
|
||||
* @date 2023-04-24
|
||||
*
|
||||
* Author: Fan Hao
|
||||
* Date: 2021-11-16 00:08
|
||||
* LastEditors: Fan Hao
|
||||
* LastEditTime: 2023-04-24 17:32
|
||||
* Revisions: Rev 0.1
|
||||
* History:
|
||||
* [2021-11-16]: Initial version.
|
||||
* [2022-06-18]: New branch for glink control purpose:
|
||||
* -Add poll mode physical layer will start Tx/Rx procedure
|
||||
* at specific time stamp.
|
||||
* [2023-04-24]: Porting for DUIFEI.
|
||||
*
|
||||
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
/**
|
||||
* @defgroup PhysicalLayer
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @name PhysicalLayer_REG_Constants
|
||||
* @{
|
||||
*/
|
||||
#ifndef PHY_REG_H_
|
||||
#define PHY_REG_H_
|
||||
|
||||
@@ -491,3 +491,7 @@
|
||||
#define PHY_DEINTLV_AMPEST_MASK 0x0000FFFFU
|
||||
|
||||
#endif /* PHY_REG_H_ */
|
||||
|
||||
/** @} PhysicalLayer_REG_Constants*/
|
||||
|
||||
/** @} PhysicalLayer*/
|
||||
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @addtogroup SystemMonitor
|
||||
* @{
|
||||
*/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
@@ -5,6 +10,10 @@
|
||||
#include "common.h"
|
||||
#include "system_monitor.h"
|
||||
/************************** Constant Definitions *****************************/
|
||||
/**
|
||||
* @name SystemMonitor_Private_Constants
|
||||
* @{
|
||||
*/
|
||||
#define BUFF_A 0x00
|
||||
#define BUFF_B 0x01
|
||||
#define BUFF_NONE 0xFF
|
||||
@@ -14,15 +23,23 @@
|
||||
#define SLOTLOG_PACK_LEN 88 // bytes
|
||||
#define PRTCLLOG_PACK_ELN 24 // bytes
|
||||
#define HWSTATE_PACK_ELN 12 // bytes
|
||||
|
||||
/** @} SystemMonitor_Private_Constants*/
|
||||
/************************** Data Type Definitions ****************************/
|
||||
/**
|
||||
* @struct PingPong
|
||||
* @brief PingPing Control
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t latest;
|
||||
uint8_t rBusy;
|
||||
uint8_t wBusy;
|
||||
uint8_t latest; ///< latest available index
|
||||
uint8_t rBusy; ///< current read busy index
|
||||
uint8_t wBusy; ///< current write busy index
|
||||
} PINGPONG;
|
||||
|
||||
/**
|
||||
* @struct System_Monitor_Inst
|
||||
* @brief System Monitor struct holds all the system log info
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
PINGPONG recvCtrl;
|
||||
@@ -64,7 +81,11 @@ inline static uint8_t GetReadable(PINGPONG ctrllor)
|
||||
return ((ctrllor.wBusy == BUFF_B) ? BUFF_A : BUFF_B);
|
||||
}
|
||||
|
||||
// System monitor initialise
|
||||
/**
|
||||
* @brief Initialize System monitor
|
||||
*
|
||||
* @return SUCCESS
|
||||
*/
|
||||
int32_t SysMonitor_Init(void)
|
||||
{
|
||||
sysMonitorInst = calloc(1, sizeof(SYSMONITOR));
|
||||
@@ -86,15 +107,23 @@ int32_t SysMonitor_Init(void)
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// System monitor initialise
|
||||
/**
|
||||
* @brief Destroy system monitor release all allocated memory
|
||||
*/
|
||||
void SysMonitor_Destroy(void)
|
||||
{
|
||||
free(sysMonitorInst);
|
||||
}
|
||||
|
||||
// @System Info
|
||||
/**
|
||||
* Update system info.
|
||||
* @name SystemInfo_API
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Update system info.
|
||||
*
|
||||
* @param info
|
||||
*/
|
||||
void SysMonitor_UpdateSysinfo(const SYSINFO *info)
|
||||
{
|
||||
@@ -107,7 +136,9 @@ void SysMonitor_UpdateSysinfo(const SYSINFO *info)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get system info.
|
||||
* @brief Get system info.
|
||||
*
|
||||
* @param info
|
||||
*/
|
||||
void SysMonitor_GetSysinfo(SYSINFO *info)
|
||||
{
|
||||
@@ -122,10 +153,18 @@ void SysMonitor_GetSysinfo(SYSINFO *info)
|
||||
memcpy(info, &(sysMonitorInst->sysInfo[buffIndx]), sizeof(SYSINFO));
|
||||
sysMonitorInst->sysInfoCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
/** @} SystemInfo_API*/
|
||||
|
||||
// @Send Payload
|
||||
/**
|
||||
* Update send payload by.
|
||||
* @name ServicePayload_API
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Update send payload by
|
||||
*
|
||||
* @param buff
|
||||
* @param len
|
||||
*/
|
||||
void SysMonitor_UpdateSendPayload(const uint8_t *buff, size_t len)
|
||||
{
|
||||
@@ -144,7 +183,11 @@ void SysMonitor_UpdateSendPayload(const uint8_t *buff, size_t len)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest send payload.
|
||||
* @brief Get the latest send payload.
|
||||
*
|
||||
* @param buff
|
||||
* @param id
|
||||
* @param len
|
||||
*/
|
||||
void SysMonitor_GetSendPayload(uint8_t *buff, uint32_t *id, size_t len)
|
||||
{
|
||||
@@ -170,9 +213,12 @@ void SysMonitor_GetSendPayload(uint8_t *buff, uint32_t *id, size_t len)
|
||||
sysMonitorInst->sendCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
|
||||
// @Receive Payload
|
||||
/**
|
||||
* Update receive payload.
|
||||
* @brief Update receive payload.
|
||||
*
|
||||
* @param buff
|
||||
* @param id
|
||||
* @param len
|
||||
*/
|
||||
void SysMonitor_UpdateRecvPayload(const uint8_t *buff, uint32_t id, size_t len)
|
||||
{
|
||||
@@ -192,14 +238,18 @@ void SysMonitor_UpdateRecvPayload(const uint8_t *buff, uint32_t id, size_t len)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest receive payload.
|
||||
* @brief Get the latest receive payload.
|
||||
*
|
||||
* @param buff
|
||||
* @param id
|
||||
* @param len
|
||||
*/
|
||||
void SysMonitor_GetRecvPayload(uint8_t *buff, uint32_t *id, size_t len)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(buff != NULL);
|
||||
ASSERT(id != NULL);
|
||||
if(len > PAYLOAD_LEN_MAX)
|
||||
if (len > PAYLOAD_LEN_MAX)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -217,10 +267,17 @@ void SysMonitor_GetRecvPayload(uint8_t *buff, uint32_t *id, size_t len)
|
||||
*id = sysMonitorInst->recv[buffIndx].dataId;
|
||||
sysMonitorInst->recvCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
/** @} ServicePayload_API*/
|
||||
|
||||
// @Link layer log
|
||||
/**
|
||||
* Update link layer log
|
||||
* @name Linklayer_Log_API
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Update link layer log
|
||||
*
|
||||
* @param log
|
||||
*/
|
||||
void SysMonitor_UpdateLinklayerLog(const LINKLOG *log)
|
||||
{
|
||||
@@ -235,7 +292,9 @@ void SysMonitor_UpdateLinklayerLog(const LINKLOG *log)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest link layer log
|
||||
* @brief Get the latest link layer log
|
||||
*
|
||||
* @param log
|
||||
*/
|
||||
void SysMonitor_GetLinklayerLog(LINKLOG *log)
|
||||
{
|
||||
@@ -251,10 +310,17 @@ void SysMonitor_GetLinklayerLog(LINKLOG *log)
|
||||
memcpy(log, &(sysMonitorInst->linkLog[buffIndx]), sizeof(LINKLOG));
|
||||
sysMonitorInst->linkLogCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
/** @} Linklayer_Log_API*/
|
||||
|
||||
// @Physical layer log
|
||||
/**
|
||||
* Update physical layer log
|
||||
* @name PhysicalLayer_Log_API
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Update physical layer log
|
||||
*
|
||||
* @param log
|
||||
*/
|
||||
void SysMonitor_UpdatePhysicalLayerLog(const PHYLOG *log)
|
||||
{
|
||||
@@ -269,7 +335,9 @@ void SysMonitor_UpdatePhysicalLayerLog(const PHYLOG *log)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest physical layer log
|
||||
* @brief Get the latest physical layer log
|
||||
*
|
||||
* @param log
|
||||
*/
|
||||
void SysMonitor_GetPhysicalLayerLog(PHYLOG *log)
|
||||
{
|
||||
@@ -285,10 +353,17 @@ void SysMonitor_GetPhysicalLayerLog(PHYLOG *log)
|
||||
memcpy(log, &(sysMonitorInst->phyLog[buffIndx]), sizeof(PHYLOG));
|
||||
sysMonitorInst->phyLogCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
/** @} */
|
||||
|
||||
// @Hardware state
|
||||
/**
|
||||
* Log hardware running status.
|
||||
* @name HardwareState_Log_API
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Log hardware running status.
|
||||
*
|
||||
* @param state
|
||||
*/
|
||||
void SysMonitor_UpdateHardwareStatus(const HWSTATE *state)
|
||||
{
|
||||
@@ -303,7 +378,9 @@ void SysMonitor_UpdateHardwareStatus(const HWSTATE *state)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest hardware running status.
|
||||
* @brief Get the latest hardware running status.
|
||||
*
|
||||
* @param state
|
||||
*/
|
||||
void SysMonitor_GetHardwareStatus(HWSTATE *state)
|
||||
{
|
||||
@@ -319,3 +396,7 @@ void SysMonitor_GetHardwareStatus(HWSTATE *state)
|
||||
memcpy(state, &(sysMonitorInst->hwState[buffIndx]), sizeof(HWSTATE));
|
||||
sysMonitorInst->hwStateCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
|
||||
/** @} HardwareState_Log_API */
|
||||
|
||||
/** @} SystemMonitor*/
|
||||
+113
-101
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @defgroup SystemMonitor
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __SYSTEM_MONITOR_H_
|
||||
#define __SYSTEM_MONITOR_H_
|
||||
|
||||
@@ -6,7 +11,11 @@
|
||||
#include <stdbool.h>
|
||||
#include "util.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
/************************* Constant Definitions ******************************/
|
||||
/**
|
||||
* @name SystemMonitor_Constants
|
||||
* @{
|
||||
*/
|
||||
#define PAYLOAD_LEN_MAX 256
|
||||
#define PAYLOAD_LEN_FLJ_RX 168
|
||||
#define PAYLOAD_LEN_FLJ_TX 66
|
||||
@@ -67,137 +76,138 @@
|
||||
#define TEMPERATURE_LSB 1.0 // Celsius degree
|
||||
#define TEMPERATURE_MAX 127.0 // Celsius degree
|
||||
#define TEMPERATURE_MIN -128.0 // Celsius degree
|
||||
/** @} SystemMonitor_Constants */
|
||||
|
||||
/************************** Data Type Definitions ****************************/
|
||||
/** @name System Info
|
||||
/************************* Data Type Definitions ****************************/
|
||||
|
||||
/**
|
||||
* @struct System_Info
|
||||
*/
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
// -- unit: ms, 0~604799999
|
||||
uint32_t psBDS;
|
||||
// -- unit: week, 0~0~8191
|
||||
uint16_t pBDS;
|
||||
// -- unit: ms, 0~604799999
|
||||
uint32_t psGPS;
|
||||
// -- unit: week, 0~0~8191
|
||||
uint16_t pGPS;
|
||||
// Time validation indicator
|
||||
// -- [0] GPS
|
||||
// -- [1] reserve.
|
||||
// -- [2] UTC
|
||||
// -- [3] BDS
|
||||
uint8_t tmInd;
|
||||
// Time of flying
|
||||
// uint: s
|
||||
float tmFly;
|
||||
// Status of flying
|
||||
// [7:6] departure status 11 - departed/00 - not departed
|
||||
// [5:4] ready status 11 - ready/00 - not ready
|
||||
// [3:2] attitude status 11 - attitude ok/00 - attitude not ok
|
||||
// [1:0] attitude adjust status 11 - adjusted/00 - not adjusted
|
||||
uint8_t stFly;
|
||||
// Position in launch coordinate system
|
||||
float posX;
|
||||
float posY;
|
||||
float posZ;
|
||||
// Speed in launch coordinate system
|
||||
float vX;
|
||||
float vY;
|
||||
float vZ;
|
||||
// Attitude in launch inertia coordinate system
|
||||
float pitch;
|
||||
float yaw;
|
||||
float roll;
|
||||
uint32_t psBDS; ///< -- unit: ms, 0~604799999
|
||||
uint16_t pBDS; ///< -- unit: week, 0~0~8191
|
||||
uint32_t psGPS; ///< -- unit: ms, 0~604799999
|
||||
uint16_t pGPS; ///< -- unit: week, 0~0~8191
|
||||
uint8_t tmInd; ///< Time validation indicator \n
|
||||
// -- [0] GPS\n
|
||||
// -- [1] reserve.\n
|
||||
// -- [2] UTC\n
|
||||
// -- [3] BDS\n
|
||||
float tmFly; ///< Time of flying uint: s
|
||||
uint8_t stFly; ///< Status of flying \n
|
||||
// [7:6] departure status 11 - departed/00 - not departed \n
|
||||
// [5:4] ready status 11 - ready/00 - not ready \n
|
||||
// [3:2] attitude status 11 - attitude ok/00 - attitude not ok \n
|
||||
// [1:0] attitude adjust status 11 - adjusted/00 - not adjusted
|
||||
float posX; ///< coord X Position in launch coordinate system
|
||||
float posY; ///< coord Y Position in launch coordinate system
|
||||
float posZ; ///< coord Z Position in launch coordinate system
|
||||
float vX; ///< Speed X in launch coordinate system
|
||||
float vY; ///< Speed Y in launch coordinate system
|
||||
float vZ; ///< Speed Z in launch coordinate system
|
||||
float pitch; ///< Pitch Attitude in launch inertia coordinate system
|
||||
float yaw; ///< Yaw Attitude in launch inertia coordinate system
|
||||
float roll; ///< Roll Attitude in launch inertia coordinate system
|
||||
} SYSINFO;
|
||||
|
||||
/** @name System Bus Log
|
||||
/**
|
||||
* @struct System_Bus_Log
|
||||
* @brief System Info holds the system bus log
|
||||
*/
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
// SystemBus log
|
||||
// -- last valid config
|
||||
// byte 0: 0x11 FLJ, 0x00 LJ
|
||||
// byte 1: 0x66 Full Power, 0x88 Low Power
|
||||
uint8_t lastConfig[2];
|
||||
uint32_t pollCnt;
|
||||
uint32_t svcCnt;
|
||||
uint32_t remoteCnt;
|
||||
|
||||
uint8_t lastConfig[2]; ///< Last valid config \n
|
||||
// byte 0: 0x11 FLJ, 0x00 LJ \n
|
||||
// byte 1: 0x66 Full Power, 0x88 Low Power
|
||||
uint32_t pollCnt; ///< number of poll commands
|
||||
uint32_t svcCnt; ///< number of service commands
|
||||
uint32_t remoteCnt; ///< number of remote check commands
|
||||
} SYSBUSLOG;
|
||||
|
||||
/** @name Linklayer Log
|
||||
/**
|
||||
* @name Linklayer_Log
|
||||
* @brief Linklayer Log struct holds the Linklayer log
|
||||
*/
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
// Network log
|
||||
uint32_t tuNum;
|
||||
uint8_t slotNum;
|
||||
uint8_t nodeType;
|
||||
uint8_t cxnStatus;
|
||||
uint8_t linkStage;
|
||||
uint32_t recxnCnt;
|
||||
uint8_t beamNo;
|
||||
uint8_t beamWidth;
|
||||
uint16_t beamAz;
|
||||
uint16_t beamEl;
|
||||
uint16_t advTxCnt;
|
||||
uint16_t advRecvCnt;
|
||||
uint16_t advCorrectCnt;
|
||||
uint32_t cfmTxCnt;
|
||||
uint32_t cfmRecvCnt;
|
||||
uint32_t cfmCorrectCnt;
|
||||
uint32_t svcTxCnt;
|
||||
uint32_t svcRecvCnt;
|
||||
uint32_t svcCorrectCnt;
|
||||
int32_t timeDev;
|
||||
uint32_t sendId;
|
||||
uint32_t recvId;
|
||||
uint8_t reserve[4];
|
||||
uint32_t tuNum; ///< current time unite number
|
||||
uint8_t slotNum; ///< current slot number
|
||||
uint8_t nodeType; ///< current node type
|
||||
uint8_t cxnStatus; ///< current connection status
|
||||
uint8_t linkStage; ///< current linklayer working stage
|
||||
uint32_t recxnCnt; ///< reconnect trial count
|
||||
uint8_t beamNo; ///< current working beam number
|
||||
uint8_t beamWidth; ///< current working beam width
|
||||
uint16_t beamAz; ///< current working beam angle Az
|
||||
uint16_t beamEl; ///< current working beam angle Ez
|
||||
uint16_t advTxCnt; ///< adv frame send count
|
||||
uint16_t advRecvCnt; ///< adv frame received count
|
||||
uint16_t advCorrectCnt; ///< adv frame received correctly count
|
||||
uint32_t cfmTxCnt; ///< cfm frame send count
|
||||
uint32_t cfmRecvCnt; ///< cfm frame received count
|
||||
uint32_t cfmCorrectCnt; ///< adv frame received correctly count
|
||||
uint32_t svcTxCnt; ///< svc frame send count
|
||||
uint32_t svcRecvCnt; ///< svc frame received count
|
||||
uint32_t svcCorrectCnt; ///< svc frame received correctly count
|
||||
int32_t timeDev; ///< last time deviation result
|
||||
uint32_t sendId; ///< last send data id
|
||||
uint32_t recvId; ///< last received data id
|
||||
uint8_t reserve[4]; ///< reserved data
|
||||
} LINKLOG;
|
||||
|
||||
/** @name Physical layer Log
|
||||
/**
|
||||
* @struct Physical_Layer_Log
|
||||
* @brief Physical Layer Log struct holds the Linklayer log
|
||||
*/
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
uint32_t acqCnt;
|
||||
uint32_t fsyncCnt;
|
||||
uint32_t decodeCnt;
|
||||
uint32_t crcCnt;
|
||||
double doppler;
|
||||
uint64_t recvStamp;
|
||||
double acqPAPR;
|
||||
uint8_t acqPhase;
|
||||
uint8_t acqFreqCh;
|
||||
double fsyncPAPR;
|
||||
uint8_t fsyncFreqCh;
|
||||
uint16_t deintlvAmpEst;
|
||||
uint8_t antMode;
|
||||
uint8_t reserve[3];
|
||||
uint32_t acqCnt; ///< aquisition count
|
||||
uint32_t fsyncCnt; ///< frame sync count
|
||||
uint32_t decodeCnt; ///< decode count
|
||||
uint32_t crcCnt; ///< crc valid count
|
||||
double doppler; ///< last doppler estimation result
|
||||
uint64_t recvStamp; ///< last frame arrival time
|
||||
double acqPAPR; ///< last acquisition peak-average ration
|
||||
uint8_t acqPhase; ///< last acquisition phase estimation
|
||||
uint8_t acqFreqCh; ///< last acquisition frequency deviation estimation
|
||||
double fsyncPAPR; ///< last frame sync peak-average ration
|
||||
uint8_t fsyncFreqCh; ///< last frame sync frequency estimation
|
||||
uint16_t deintlvAmpEst; ///< de-interleave amplitude estimation
|
||||
uint8_t antMode; ///< current antenna working mode
|
||||
uint8_t reserve[3]; ///< reserved data
|
||||
} PHYLOG;
|
||||
|
||||
/** @name Hardware Status Log
|
||||
/**
|
||||
* @struct Hardware_Status_Log
|
||||
* @brief Hardware Status Log struct holds all hardware status
|
||||
*/
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
// Hardware status
|
||||
bool isSpOk;
|
||||
bool isAntOk;
|
||||
bool isSpOk; ///< signal processor state
|
||||
bool isAntOk; ///< antenna state
|
||||
// -- Signal processor status
|
||||
uint8_t spFpgaVolt;
|
||||
uint8_t spClkState;
|
||||
uint8_t spAdLockState;
|
||||
uint8_t spAdTemp_0;
|
||||
uint8_t spAdTemp_1;
|
||||
uint8_t spFpgaTemp;
|
||||
uint8_t spFpgaVolt; ///< Signal processor voltage state indicator
|
||||
uint8_t spClkState; ///< Signal processor clock state indicator
|
||||
uint8_t spAdLockState; ///< Signal processor adc lock state indicator
|
||||
uint8_t spAdTemp_0; ///< Signal processor adc0 temperature
|
||||
uint8_t spAdTemp_1; ///< Signal processor adc1 temperature
|
||||
uint8_t spFpgaTemp; ///< Signal processor FPGA temperature
|
||||
// -- Antenna status
|
||||
uint8_t antVolt;
|
||||
uint8_t antTemp;
|
||||
uint8_t antPll;
|
||||
uint8_t antMgc0;
|
||||
uint8_t antMgc1;
|
||||
uint8_t antVolt; ///< Antenna voltage state indicator
|
||||
uint8_t antTemp; ///< Antenna rf temperature
|
||||
uint8_t antPll; ///< Antenna rf lock state indicator
|
||||
uint8_t antMgc0; ///< Antenna rf mgc0~1 indicator
|
||||
uint8_t antMgc1; ///< Antenna rf mgc2~3 indicator
|
||||
uint8_t reserve[2];
|
||||
} HWSTATE;
|
||||
|
||||
/** @name Payload
|
||||
/**
|
||||
* @struct Payload
|
||||
* @brief Payload struct holds the service payload
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
@@ -225,3 +235,5 @@ void SysMonitor_GetPhysicalLayerLog(PHYLOG *log);
|
||||
void SysMonitor_GetHardwareStatus(HWSTATE *state);
|
||||
|
||||
#endif //__SYSTEM_MONITOR_H_
|
||||
|
||||
/** @} */
|
||||
@@ -1,22 +1,21 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: System bus protocol implementation file.
|
||||
* @file systembus.c
|
||||
* @author FanHao ([email protected])
|
||||
* @brief System bus protocol implementation file.
|
||||
* @version 0.1
|
||||
* @date 2023-05-06
|
||||
*
|
||||
* Date: 2023-05-06 10:13
|
||||
* Last Edit Time: [2023-05-06 21:45]
|
||||
*
|
||||
* Revisions: Rev 0.0
|
||||
* History:
|
||||
* [2023-05-06]: Initial version.
|
||||
* [2023-09-13]: Update to 485 protocol-20220816
|
||||
*
|
||||
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup SystemBus
|
||||
* @{
|
||||
*/
|
||||
/***************************** Include Files *********************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
@@ -31,6 +30,10 @@
|
||||
#include "../system_monitor.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
/**
|
||||
* @name SystemBus_MSG_Constants
|
||||
* @{
|
||||
*/
|
||||
// Common Field
|
||||
// -- Command word
|
||||
#define WD_CMD 0x00
|
||||
@@ -192,7 +195,7 @@
|
||||
|
||||
// My Production Type
|
||||
#define MY_PRD_ID PRD_DL_K
|
||||
|
||||
/** @} SystemBus_MSG_Constants*/
|
||||
/************************** Function Prototypes ******************************/
|
||||
static int32_t SystemBus_GenSelfTestRsp(SYSBUS *instPtr);
|
||||
static int32_t SystemBus_SystemConfig(SYSBUS *instPtr, uint8_t *msg);
|
||||
@@ -752,3 +755,5 @@ recv_error:
|
||||
free(sysbusReq);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/** @} SystemBus*/
|
||||
@@ -1,18 +1,20 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: System bus protocol head file.
|
||||
* @file systembus.h
|
||||
* @author FanHao ([email protected])
|
||||
* @brief System bus protocol header file.
|
||||
* @version 0.1
|
||||
* @date 2023-05-06
|
||||
*
|
||||
* Date: 2023-05-06 10:12
|
||||
* Last Edit Time: [2023-05-06 10:13]
|
||||
*
|
||||
* Revisions: Rev 0.0
|
||||
* History:
|
||||
* [2023-05-06]: Initial version.
|
||||
*
|
||||
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @defgroup SystemBus
|
||||
* @{
|
||||
*/
|
||||
#ifndef __SYSTEMBUS_H_
|
||||
#define __SYSTEMBUS_H_
|
||||
|
||||
@@ -25,26 +27,34 @@
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
/************************** Data Type Definitions ****************************/
|
||||
// Definition of SystemBus instance.
|
||||
|
||||
/**
|
||||
* @struct SystemBus Config
|
||||
* @brief SystemBus Config struct holds SystemBus initialization parameters
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uintptr_t baseAddr;
|
||||
uint32_t txQueueMax;
|
||||
uint32_t rxQueueMax;
|
||||
uintptr_t baseAddr; ///< base address in memory
|
||||
uint32_t txQueueMax; ///< maximum tx queue length
|
||||
uint32_t rxQueueMax; ///< maximum rx queue length
|
||||
} SYSBUS_CONFIG;
|
||||
|
||||
/**
|
||||
* @struct SystemBus Instance
|
||||
* @brief SystemBus Instance struct
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
SYSBUS_CONFIG config;
|
||||
SYSBUSLOG sysbusLog; // systembus log
|
||||
LINKLOG linkLog; // Link layer log
|
||||
PHYLOG phyLog; // Physical layer log
|
||||
HWSTATE hwState; // Hardware status
|
||||
SYSBUS_UART *uartInst;
|
||||
CIRC_QUEUE *txQueue;
|
||||
CIRC_QUEUE *rxQueue;
|
||||
bool isRxDone;
|
||||
bool isTxDone;
|
||||
SYSBUS_CONFIG config; ///< SystemBus initialization parameters
|
||||
SYSBUSLOG sysbusLog; ///< SystemBus log
|
||||
LINKLOG linkLog; ///< Link layer log
|
||||
PHYLOG phyLog; ///< Physical layer log
|
||||
HWSTATE hwState; ///< Hardware status
|
||||
SYSBUS_UART *uartInst; ///< physical uart controller instance
|
||||
CIRC_QUEUE *txQueue; ///< tx queue
|
||||
CIRC_QUEUE *rxQueue; ///< rx queue
|
||||
bool isRxDone; ///< tx done indicator
|
||||
bool isTxDone; ///< rx done indicator
|
||||
} SYSBUS;
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
@@ -64,3 +74,5 @@ bool SystemBus_IsTxBusy(SYSBUS *instPtr);
|
||||
bool SystemBus_IsRxBusy(SYSBUS *instPtr);
|
||||
|
||||
#endif //__SYSTEMBUS_H_
|
||||
|
||||
/** @} SystemBus*/
|
||||
@@ -1,18 +1,26 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: System bus uart driver implementation file.
|
||||
* @file systembus_uart.h
|
||||
* @author FanHao (hao_fan_bit_ee@163.com)
|
||||
* @brief System bus uart driver implementation file.
|
||||
* @version 0.1
|
||||
* @date 2023-05-06
|
||||
*
|
||||
* Date: 2023-05-06 10:59
|
||||
* LastEditTime: 2023-05-06 21:56
|
||||
* Revisions: Rev 0.0
|
||||
* History:
|
||||
* [2023-05-06]: Initial version.
|
||||
*
|
||||
* Copyright(c) 2022 Beijing Institute of Technology.
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
/**
|
||||
* @addtogroup SystemBus
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup SystemBus_UART
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/***************************** Include Files *******************************/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
@@ -20,6 +28,10 @@
|
||||
#include "systembus_uart.h"
|
||||
#include "common.h"
|
||||
|
||||
/**
|
||||
* @name SystemBus_UART_Driver_Constants
|
||||
* @{
|
||||
*/
|
||||
// Control and status register
|
||||
#define MODULE_VERSION 0
|
||||
#define UART_STATUS 4
|
||||
@@ -47,7 +59,7 @@
|
||||
#define FRAME_CHECK_LEN 1 // CheckSum
|
||||
#define FRAME_INFO_LEN 3 // CheckSum, Dummy and DataLen
|
||||
#define FRAME_OVERHEAD_LEN 7 // CheckSum, Dummy and DataLen
|
||||
/*************************** Function Definitions ****************************/
|
||||
/** @} SystemBus_UART_Driver_Constants*/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
@@ -246,3 +258,7 @@ bool SysbusUart_IsTxBusy(SYSBUS_UART *instPtr)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** @} SystemBus_UART*/
|
||||
|
||||
/** @} SystemBus*/
|
||||
@@ -1,17 +1,25 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: System bus uart driver implementation file.
|
||||
* @file systembus_uart.h
|
||||
* @author FanHao (hao_fan_bit_ee@163.com)
|
||||
* @brief System bus uart driver header file.
|
||||
* @version 0.1
|
||||
* @date 2023-05-06
|
||||
*
|
||||
* Date: 2023-05-06 10:59
|
||||
* LastEditTime: 2023-05-06 21:48
|
||||
* Revisions: Rev 0.0
|
||||
* History:
|
||||
* [2023-05-06]: Initial version.
|
||||
*
|
||||
* Copyright(c) 2022 Beijing Institute of Technology.
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup SystemBus
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup SystemBus_UART
|
||||
* @{
|
||||
*/
|
||||
#ifndef SYSTEMBUS_UART_H
|
||||
#define SYSTEMBUS_UART_H
|
||||
|
||||
@@ -96,3 +104,7 @@ bool SysbusUart_IsRxBusy(SYSBUS_UART *instPtr);
|
||||
bool SysbusUart_IsTxBusy(SYSBUS_UART *instPtr);
|
||||
|
||||
#endif // SYSTEMBUS_UART_H
|
||||
|
||||
/** @} SystemBus_UART*/
|
||||
|
||||
/** @} SystemBus*/
|
||||
@@ -1,20 +1,21 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: Time sync implementation file.
|
||||
*
|
||||
* Author: Author's name
|
||||
* Date: 2023-12-20 16:32
|
||||
* LastEditors: FanHao
|
||||
* LastEditTime: 2023-12-22 20:43
|
||||
* Revisions: Rev 0.0
|
||||
* History:
|
||||
* [2023-12-20]: Initial version.
|
||||
*
|
||||
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
* @file time_ctrl.c
|
||||
* @author FanHao (hao_fan_bit_ee@163.com)
|
||||
* @brief Time sync controller driver implementation file.
|
||||
* @version 0.0
|
||||
* @date 2023-12-20
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup TimeController_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
#include <string.h>
|
||||
#include "time_ctrl.h"
|
||||
@@ -23,6 +24,10 @@
|
||||
#include "util.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
/**
|
||||
* @name TimeController_REG_Constants
|
||||
* @{
|
||||
*/
|
||||
#define VERSION_REG 0x00000004
|
||||
#define TIME_INT_REG 0x00000008
|
||||
#define TIME_FRAC_REG 0x0000000C
|
||||
@@ -36,6 +41,9 @@
|
||||
#define CNTSTEP_OPT 0x0000002c
|
||||
|
||||
#define TM_RESET_CODE 0x5253542E
|
||||
|
||||
/** @} TimeController_REG_Constants*/
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
#define TMC_Read(instPtr, addr) IO_In32(instPtr->config.baseAddr + addr)
|
||||
#define TMC_Write(instPtr, addr, value) IO_Out32(instPtr->config.baseAddr + addr, value)
|
||||
@@ -296,3 +304,5 @@ void TimeCtrl_CalculateTimeGap(const TIME_WORD *a, const TIME_WORD *b, TIME_WORD
|
||||
gap->frac_part = (TIME_FRAC)(timeDiff % TIME_FRAC_MAX);
|
||||
gap->frac_part = (TIME_INT)(timeDiff / TIME_FRAC_MAX);
|
||||
}
|
||||
|
||||
/** @} TimeController_Driver*/
|
||||
@@ -1,19 +1,20 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: A simplified version of timesync for datalink 814 (Dijian)
|
||||
*
|
||||
* Date: 2023-12-20-04 16:32
|
||||
* LastEditors: Fan Hao
|
||||
* LastEditTime: 2023-12-20 16:32
|
||||
* Revisions: Rev 0.0
|
||||
* History:
|
||||
* [2023-12-20]: Initial version.
|
||||
*
|
||||
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
* @file time_ctrl.h
|
||||
* @author FanHao (hao_fan_bit_ee@163.com)
|
||||
* @brief Time sync controller driver header file.
|
||||
* @version 0.0
|
||||
* @date 2023-12-20
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @defgroup TimeController_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef TIME_CTRL_H_
|
||||
#define TIME_CTRL_H_
|
||||
|
||||
@@ -23,30 +24,43 @@
|
||||
#define TIME_FRAC_MAX 500000 // how many 10ns in a 5ms
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
/**************************** Type Definitions *******************************/
|
||||
/**
|
||||
* @enum TIMECTRL_ADJ_TYPE
|
||||
* @brief defines the time adjustment methods
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
TM_ADJ_NONE = 0,
|
||||
TM_ADJ_ADD = 1,
|
||||
TM_ADJ_SET = 2
|
||||
TM_ADJ_NONE = 0, ///< none
|
||||
TM_ADJ_ADD = 1, ///< adjust time by add
|
||||
TM_ADJ_SET = 2 ///< adjust time by set
|
||||
} TIMECTRL_ADJ_TYPE;
|
||||
|
||||
typedef uint32_t TIME_FRAC;
|
||||
typedef uint32_t TIME_INT;
|
||||
|
||||
/**
|
||||
* @struct TimeWord
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/* 5ms each LSB */
|
||||
TIME_INT int_part;
|
||||
/* 10ns each LSB */
|
||||
TIME_FRAC frac_part;
|
||||
TIME_INT int_part; ///< 5ms each LSB
|
||||
TIME_FRAC frac_part; ///< 10ns each LSB
|
||||
} TIME_WORD;
|
||||
|
||||
/**
|
||||
* @struct TmcConfig.
|
||||
* @brief TmcConfig holds the initialization parameters of time controller
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uintptr_t baseAddr;
|
||||
uint32_t reset; // time for reset (unit: us)
|
||||
} TMC_CONFIG;
|
||||
|
||||
/**
|
||||
* @struct TmcInst.
|
||||
* @brief An instance struct of time controller
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
TMC_CONFIG config;
|
||||
@@ -72,3 +86,5 @@ void TimeCtrl_TimeAdjust(TMC_INST *instPtr, const TIME_WORD *tmWord, TIMECTRL_AD
|
||||
void TimeCtrl_CalculateTimeGap(const TIME_WORD *a, const TIME_WORD *b, TIME_WORD *gap);
|
||||
|
||||
#endif /* TIME_SYNC_H_ */
|
||||
|
||||
/** @} */
|
||||
@@ -1,34 +1,25 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* Description: A simple circular FIFO bounded queue
|
||||
* @file circ_queue.c
|
||||
* @author FanHao (hao_fan_bit_ee@163.com)
|
||||
* @brief A simple circular FIFO bounded queue
|
||||
* @version 0.1
|
||||
* @date 2023-02-23
|
||||
* @note Forked from https://github.com/chrismerck/rpa_queue.git
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
* Author: Fan Hao
|
||||
* Date: 2023-02-23 10:29
|
||||
* LastEditors: Fan Hao
|
||||
* LastEditTime: 2023-02-23 13:18
|
||||
* Revisions: Rev 0.0
|
||||
* History:
|
||||
* [2023-02-23]: Initial Version.
|
||||
*
|
||||
* Copyright(c) 2023 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
* NOTE: Forked from https://github.com/chrismerck/rpa_queue.git
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup Utility
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup CircularQueue
|
||||
* @{
|
||||
*/
|
||||
#include "circ_queue.h"
|
||||
#include "common.h"
|
||||
#include <stdio.h>
|
||||
@@ -56,7 +47,7 @@ void CircQueueFree(CIRC_QUEUE *queue)
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the CIRC_QUEUE.
|
||||
* @brief Initialize the CIRC_QUEUE.
|
||||
*/
|
||||
bool CircQueueCreate(CIRC_QUEUE **q, uint32_t queueCapacity)
|
||||
{
|
||||
@@ -87,7 +78,7 @@ error:
|
||||
}
|
||||
|
||||
/**
|
||||
* Push new data onto the queue.
|
||||
* @brief Push new data onto the queue.
|
||||
*/
|
||||
bool CircQueuePush(CIRC_QUEUE *queue, void *data)
|
||||
{
|
||||
@@ -110,7 +101,7 @@ bool CircQueuePush(CIRC_QUEUE *queue, void *data)
|
||||
}
|
||||
|
||||
/**
|
||||
* Return current number of element in queue.
|
||||
* @brief Return current number of element in queue.
|
||||
*/
|
||||
inline uint32_t CircQueueSize(CIRC_QUEUE *queue)
|
||||
{
|
||||
@@ -118,7 +109,7 @@ inline uint32_t CircQueueSize(CIRC_QUEUE *queue)
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the next item from the queue.
|
||||
* @brief Retrieves the next item from the queue.
|
||||
*/
|
||||
bool CircQueuePop(CIRC_QUEUE *queue, void **data)
|
||||
{
|
||||
@@ -139,3 +130,5 @@ bool CircQueuePop(CIRC_QUEUE *queue, void **data)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/** @} CircularQueue*/
|
||||
/** @} Utility*/
|
||||
@@ -1,3 +1,25 @@
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @file clist.c
|
||||
* @author FanHao (hao_fan_bit_ee@163.com)
|
||||
* @brief A basic list data structure
|
||||
* @version 0.1
|
||||
* @date 2023-02-23
|
||||
* @note Forked from https://github.com/clibs/list
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup Utility
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup cList
|
||||
* @{
|
||||
*/
|
||||
#ifndef LIST_MALLOC
|
||||
#define LIST_MALLOC malloc
|
||||
#endif
|
||||
@@ -6,19 +28,12 @@
|
||||
#define LIST_FREE free
|
||||
#endif
|
||||
|
||||
//
|
||||
// list.c
|
||||
//
|
||||
// Copyright (c) 2010 TJ Holowaychuk <[email protected]>
|
||||
//
|
||||
|
||||
#include <stdint.h>
|
||||
#include "clist.h"
|
||||
|
||||
/*
|
||||
* Allocates a new clist_node_t. NULL on failure.
|
||||
/**
|
||||
* @brief a new clist_node_t. NULL on failure.
|
||||
*/
|
||||
|
||||
clist_node_t *
|
||||
clist_node_new(void *val)
|
||||
{
|
||||
@@ -31,10 +46,9 @@ clist_node_new(void *val)
|
||||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate a new clist_t. NULL on failure.
|
||||
/**
|
||||
* @brief Allocate a new clist_t. NULL on failure.
|
||||
*/
|
||||
|
||||
clist_t *
|
||||
clist_new(void)
|
||||
{
|
||||
@@ -49,11 +63,10 @@ clist_new(void)
|
||||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove all the node in list.
|
||||
* @self: Pointer to the list
|
||||
/**
|
||||
* @brief Remove all the node in list.
|
||||
* @param self: Pointer to the list
|
||||
*/
|
||||
|
||||
void clist_clear(clist_t *self)
|
||||
{
|
||||
clist_node_t *next;
|
||||
@@ -71,24 +84,21 @@ void clist_clear(clist_t *self)
|
||||
self->head = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free the list.
|
||||
* @self: Pointer to the list
|
||||
/**
|
||||
* @brief Free the list.
|
||||
* @param self: Pointer to the list
|
||||
*/
|
||||
|
||||
void clist_destroy(clist_t *self)
|
||||
{
|
||||
clist_clear(self);
|
||||
LIST_FREE(self);
|
||||
}
|
||||
|
||||
/*
|
||||
* Append the given node to the list
|
||||
* and return the node, NULL on failure.
|
||||
* @self: Pointer to the list for popping node
|
||||
* @node: the node to push
|
||||
/**
|
||||
* @brief Append the given node to the list and return the node, NULL on failure.
|
||||
* @param self: Pointer to the list for popping node
|
||||
* @param node: the node to push
|
||||
*/
|
||||
|
||||
clist_node_t *
|
||||
clist_rpush(clist_t *self, clist_node_t *node)
|
||||
{
|
||||
@@ -112,9 +122,9 @@ clist_rpush(clist_t *self, clist_node_t *node)
|
||||
return node;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return / detach the last node in the list, or NULL.
|
||||
* @self: Pointer to the list for popping node
|
||||
/**
|
||||
* @brief Return / detach the last node in the list, or NULL.
|
||||
* @param self: Pointer to the list for popping node
|
||||
*/
|
||||
|
||||
clist_node_t *
|
||||
@@ -138,9 +148,9 @@ clist_rpop(clist_t *self)
|
||||
return node;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return / detach the first node in the list, or NULL.
|
||||
* @self: Pointer to the list for popping node
|
||||
/**
|
||||
* @brief Return / detach the first node in the list, or NULL.
|
||||
* @param self: Pointer to the list for popping node
|
||||
*/
|
||||
|
||||
clist_node_t *
|
||||
@@ -164,11 +174,10 @@ clist_lpop(clist_t *self)
|
||||
return node;
|
||||
}
|
||||
|
||||
/*
|
||||
* Prepend the given node to the list
|
||||
* and return the node, NULL on failure.
|
||||
* @self: Pointer to the list for pushing node
|
||||
* @node: the node to push
|
||||
/**
|
||||
* @brief Prepend the given node to the list and return the node, NULL on failure.
|
||||
* @param self: Pointer to the list for pushing node
|
||||
* @param node: the node to push
|
||||
*/
|
||||
|
||||
clist_node_t *
|
||||
@@ -194,10 +203,10 @@ clist_lpush(clist_t *self, clist_node_t *node)
|
||||
return node;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the node associated to val or NULL.
|
||||
* @self: Pointer to the list for finding given value
|
||||
* @val: Value to find
|
||||
/**
|
||||
* @brief Return the node associated to val or NULL.
|
||||
* @param self: Pointer to the list for finding given value
|
||||
* @param val: Value to find
|
||||
*/
|
||||
|
||||
clist_node_t *
|
||||
@@ -230,10 +239,10 @@ clist_find(clist_t *self, void *val)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the node at the given index or NULL.
|
||||
* @self: Pointer to the list for finding given index
|
||||
* @index: the index of node in the list
|
||||
/**
|
||||
* @brief Return the node at the given index or NULL.
|
||||
* @param self: Pointer to the list for finding given index
|
||||
* @param index: the index of node in the list
|
||||
*/
|
||||
|
||||
clist_node_t *
|
||||
@@ -260,10 +269,10 @@ clist_at(clist_t *self, int index)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove the given node from the list, freeing it and it's value.
|
||||
* @self: Pointer to the list to delete a node
|
||||
* @node: Pointer the node to be deleted
|
||||
/**
|
||||
* @brief Remove the given node from the list, freeing it and it's value.
|
||||
* @param self: Pointer to the list to delete a node
|
||||
* @param node: Pointer the node to be deleted
|
||||
*/
|
||||
|
||||
void clist_remove(clist_t *self, clist_node_t *node)
|
||||
@@ -283,8 +292,8 @@ void clist_remove(clist_t *self, clist_node_t *node)
|
||||
--self->len;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate a new clist_iterator_t. NULL on failure.
|
||||
/**
|
||||
* @brief Allocate a new clist_iterator_t. NULL on failure.\n
|
||||
* Accepts a direction, which may be LIST_HEAD or LIST_TAIL.
|
||||
*/
|
||||
|
||||
@@ -297,8 +306,8 @@ clist_iterator_new(clist_t *list, clist_direction_t direction)
|
||||
return clist_iterator_new_from_node(node, direction);
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate a new clist_iterator_t with the given start
|
||||
/**
|
||||
* @brief Allocate a new clist_iterator_t with the given start
|
||||
* node. NULL on failure.
|
||||
*/
|
||||
|
||||
@@ -313,8 +322,8 @@ clist_iterator_new_from_node(clist_node_t *node, clist_direction_t direction)
|
||||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the next clist_node_t or NULL when no more
|
||||
/**
|
||||
* @brief Return the next clist_node_t or NULL when no more
|
||||
* nodes remain in the list.
|
||||
*/
|
||||
|
||||
@@ -331,8 +340,8 @@ clist_iterator_next(clist_iterator_t *self)
|
||||
return curr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free the list iterator.
|
||||
/**
|
||||
* @brief Free the list iterator.
|
||||
*/
|
||||
|
||||
void clist_iterator_destroy(clist_iterator_t *self)
|
||||
@@ -340,3 +349,5 @@ void clist_iterator_destroy(clist_iterator_t *self)
|
||||
LIST_FREE(self);
|
||||
self = NULL;
|
||||
}
|
||||
/** @} cList*/
|
||||
/** @} Utility*/
|
||||
@@ -10,11 +10,14 @@
|
||||
* [2022-07-16]: New branch for Dijian.
|
||||
* [2021-11-16]: Initial version.
|
||||
*
|
||||
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||
* Copyright(c) 2024 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup COMMON_MACRO
|
||||
* @{
|
||||
*/
|
||||
/***************************** Include Files *********************************/
|
||||
#include "common.h"
|
||||
#include "error.h"
|
||||
@@ -44,3 +47,5 @@ void AppAssert(const char *file, int line)
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
@@ -11,11 +11,14 @@
|
||||
* [2022-07-17]: Add CRC16_0x8005 CRC8_0x31.
|
||||
* [2022-01-06]: Initial verion (Basic CRC-16).
|
||||
*
|
||||
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||
* Copyright(c) 2024 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup Utility
|
||||
* @{
|
||||
*/
|
||||
#include "util.h"
|
||||
#include "error.h"
|
||||
|
||||
@@ -437,3 +440,5 @@ bool crc16_check(uint8_t *buffPtr, uint32_t dataLen, uint32_t crcOffset, uint16_
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** @}*/
|
||||
@@ -1,15 +1,30 @@
|
||||
/******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @file util.c
|
||||
* @author FanHao (hao_fan_bit_ee@163.com)
|
||||
* @brief Utility functions implementation file
|
||||
* @version 0.0
|
||||
* @date 2023-05-06
|
||||
*
|
||||
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
|
||||
* Lab of Communication and Network
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************** Include Files **********************************/
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup Utility
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
// #include <arm_acle.h>
|
||||
#include "util.h"
|
||||
#include "error.h"
|
||||
|
||||
/******************************************************************************/
|
||||
/************************** Functions Implementation **************************/
|
||||
/******************************************************************************/
|
||||
#ifdef __BITSWAP_TABLE
|
||||
static uint8_t byte_flipLR[256] =
|
||||
{
|
||||
@@ -48,17 +63,26 @@ static uint8_t byte_flipLR[256] =
|
||||
};
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Write a 32bit word to specific memory address
|
||||
*/
|
||||
inline void IO_Out32(uintptr_t addr, uint32_t value)
|
||||
{
|
||||
volatile uint32_t *localAddr = (volatile uint32_t *)addr;
|
||||
*localAddr = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read a 32bit word from specific memory address
|
||||
*/
|
||||
inline uint32_t IO_In32(uintptr_t addr)
|
||||
{
|
||||
return *(volatile uint32_t *)addr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Swap a byte word bit-wise
|
||||
*/
|
||||
uint8_t byte_bit_swap(uint8_t byte)
|
||||
{
|
||||
#ifdef __BITSWAP_TABLE
|
||||
@@ -68,6 +92,9 @@ uint8_t byte_bit_swap(uint8_t byte)
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Swap 32bit word bit-wise
|
||||
*/
|
||||
uint32_t word_bit_swap(uint32_t word)
|
||||
{
|
||||
#ifdef __BITSWAP_TABLE
|
||||
@@ -85,6 +112,9 @@ uint32_t word_bit_swap(uint32_t word)
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Count ones in an 32bit word
|
||||
*/
|
||||
uint32_t count_ones(uint32_t word)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
@@ -101,13 +131,16 @@ uint32_t count_ones(uint32_t word)
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Convert fix ;oint number to float number
|
||||
*/
|
||||
double fix2double(int32_t val, uint8_t frac_bits)
|
||||
{
|
||||
return (((double)val) / (BIT(frac_bits)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Find first set bit in word.
|
||||
* @brief Find first set bit in word.
|
||||
*/
|
||||
uint32_t find_first_set_bit(uint32_t word)
|
||||
{
|
||||
@@ -136,7 +169,7 @@ uint32_t find_first_set_bit(uint32_t word)
|
||||
}
|
||||
|
||||
/**
|
||||
* Find last set bit in word.
|
||||
* @brief Find last set bit in word.
|
||||
*/
|
||||
uint32_t find_last_set_bit(uint32_t word)
|
||||
{
|
||||
@@ -166,7 +199,7 @@ uint32_t find_last_set_bit(uint32_t word)
|
||||
}
|
||||
|
||||
/**
|
||||
* Locate the closest element in an array.
|
||||
* @brief Locate the closest element in an array.
|
||||
*/
|
||||
uint32_t find_closest(int32_t val,
|
||||
const int32_t *array,
|
||||
@@ -189,7 +222,7 @@ uint32_t find_closest(int32_t val,
|
||||
}
|
||||
|
||||
/**
|
||||
* Shift the value and apply the specified mask.
|
||||
* @brief Shift the value and apply the specified mask.
|
||||
*/
|
||||
uint32_t field_prep(uint32_t mask, uint32_t val)
|
||||
{
|
||||
@@ -197,7 +230,7 @@ uint32_t field_prep(uint32_t mask, uint32_t val)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a field specified by a mask from a word.
|
||||
* @brief Get a field specified by a mask from a word.
|
||||
*/
|
||||
uint32_t field_get(uint32_t mask, uint32_t word)
|
||||
{
|
||||
@@ -205,7 +238,7 @@ uint32_t field_get(uint32_t mask, uint32_t word)
|
||||
}
|
||||
|
||||
/**
|
||||
* Log base 2 of the given number.
|
||||
* @brief Log base 2 of the given number.
|
||||
*/
|
||||
int32_t log_base_2(uint32_t x)
|
||||
{
|
||||
@@ -213,7 +246,7 @@ int32_t log_base_2(uint32_t x)
|
||||
}
|
||||
|
||||
/**
|
||||
* Find greatest common divisor of the given two numbers.
|
||||
* @brief Find greatest common divisor of the given two numbers.
|
||||
*/
|
||||
uint32_t greatest_common_divisor(uint32_t a,
|
||||
uint32_t b)
|
||||
@@ -232,7 +265,7 @@ uint32_t greatest_common_divisor(uint32_t a,
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate best rational approximation for a given fraction.
|
||||
* @brief Calculate best rational approximation for a given fraction.
|
||||
*/
|
||||
void rational_best_approximation(uint32_t given_numerator,
|
||||
uint32_t given_denominator,
|
||||
@@ -257,7 +290,7 @@ void rational_best_approximation(uint32_t given_numerator,
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the number of set bits.
|
||||
* @brief Calculate the number of set bits.
|
||||
*/
|
||||
uint32_t hweight8(uint32_t word)
|
||||
{
|
||||
@@ -274,7 +307,7 @@ uint32_t hweight8(uint32_t word)
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the quotient and the remainder of an integer division.
|
||||
* @brief Calculate the quotient and the remainder of an integer division.
|
||||
*/
|
||||
uint64_t do_div(uint64_t *n,
|
||||
uint64_t base)
|
||||
@@ -288,7 +321,7 @@ uint64_t do_div(uint64_t *n,
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsigned 64bit divide with 64bit divisor and remainder
|
||||
* @brief Unsigned 64bit divide with 64bit divisor and remainder
|
||||
*/
|
||||
uint64_t div64_u64_rem(uint64_t dividend, uint64_t divisor, uint64_t *remainder)
|
||||
{
|
||||
@@ -298,7 +331,7 @@ uint64_t div64_u64_rem(uint64_t dividend, uint64_t divisor, uint64_t *remainder)
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsigned 64bit divide with 32bit divisor with remainder
|
||||
* @brief Unsigned 64bit divide with 32bit divisor with remainder
|
||||
*/
|
||||
uint64_t div_u64_rem(uint64_t dividend, uint32_t divisor, uint32_t *remainder)
|
||||
{
|
||||
@@ -308,7 +341,7 @@ uint64_t div_u64_rem(uint64_t dividend, uint32_t divisor, uint32_t *remainder)
|
||||
}
|
||||
|
||||
/**
|
||||
* Signed 64bit divide with 32bit divisor with remainder
|
||||
* @brief Signed 64bit divide with 32bit divisor with remainder
|
||||
*/
|
||||
int64_t div_s64_rem(int64_t dividend, int32_t divisor, int32_t *remainder)
|
||||
{
|
||||
@@ -317,7 +350,7 @@ int64_t div_s64_rem(int64_t dividend, int32_t divisor, int32_t *remainder)
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsigned 64bit divide with 32bit divisor
|
||||
* @brief Unsigned 64bit divide with 32bit divisor
|
||||
*/
|
||||
uint64_t div_u64(uint64_t dividend, uint32_t divisor)
|
||||
{
|
||||
@@ -327,7 +360,7 @@ uint64_t div_u64(uint64_t dividend, uint32_t divisor)
|
||||
}
|
||||
|
||||
/**
|
||||
* Signed 64bit divide with 32bit divisor
|
||||
* @brief Signed 64bit divide with 32bit divisor
|
||||
*/
|
||||
int64_t div_s64(int64_t dividend, int32_t divisor)
|
||||
{
|
||||
@@ -336,7 +369,7 @@ int64_t div_s64(int64_t dividend, int32_t divisor)
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts from string to int32_t
|
||||
* @brief Converts from string to int32_t
|
||||
* @param *str
|
||||
* @return int32_t
|
||||
*/
|
||||
@@ -352,7 +385,7 @@ int32_t str_to_int32(const char *str)
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts from string to uint32_t
|
||||
* @brief Converts from string to uint32_t
|
||||
* @param *str
|
||||
* @return uint32_t
|
||||
*/
|
||||
@@ -366,3 +399,5 @@ uint32_t srt_to_uint32(const char *str)
|
||||
else
|
||||
return value;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
Reference in New Issue
Block a user