更新evt v1.3

This commit is contained in:
stark1898y 2025-03-27 10:22:43 +08:00
parent 513fbdfdbf
commit afa04bd401
27 changed files with 23859 additions and 23749 deletions

View File

@ -215,15 +215,15 @@ int main(void)
BSP_KEY_Init(app_task_handler);
// IWDG_Init(1500);
DelayMs(1000 * 3);
// DelayMs(1000 * 3);
BSP_ADC_Init();
BSP_VAVLE_Init();
HAL_Init();
GAPRole_PeripheralInit();
Peripheral_Init();
// HAL_Init();
// GAPRole_PeripheralInit();
// Peripheral_Init();
BSP_BlockSleep();
BSP_RequestBoost();

View File

@ -254,7 +254,7 @@ void BSP_KEY_Init(app_task_evt_handler_t handler)
// MCU_LDECT
// GPIOA_ModeCfg(GPIO_Pin_2, GPIO_ModeIN_PU);
GPIOB_ModeCfg(GPIO_Pin_16, GPIO_ModeIN_Floating);
// GPIOB_ModeCfg(GPIO_Pin_16, GPIO_ModeIN_Floating);
GPIOB_ModeCfg(GPIO_Pin_0, GPIO_ModeIN_Floating);
// GPIOB_ModeCfg(GPIO_Pin_1, GPIO_ModeIN_Floating);

View File

@ -1,3 +1,13 @@
/*
* @Author : stark1898y 1658608470@qq.com
* @Date : 2024-12-30 10:11:28
* @LastEditors : stark1898y 1658608470@qq.com
* @LastEditTime : 2025-03-27 10:11:31
* @FilePath : \BLE_TYQ_CH584M\HAL\LED.c
* @Description :
*
* Copyright (c) 2025 by yzy, All Rights Reserved.
*/
/********************************** (C) COPYRIGHT *******************************
* File Name : LED.c
* Author : WCH
@ -14,8 +24,6 @@
/* Í·Îļþ°üº¬ */
#include "HAL.h"
#include "bsp_beep_led_emv.h"
/* LED control structure */
typedef struct
{
@ -60,16 +68,10 @@ void HalLedOnOff(uint8_t leds, uint8_t mode);
void HAL_LedInit(void)
{
/* Initialize all LEDs to OFF */
LEDR_DDR;
LEDG_DDR;
LEDY_DDR;
BEEP_DDR;
LED1_DDR;
HalLedSet(HAL_LED_ALL, HAL_LED_MODE_OFF);
BOOST_EN;
// just test
HalLedBlink(HAL_LED_R, 10, 50, 200);
HalLedBlink(HAL_LED_1, 10, 30, 4000);
/* Initialize sleepActive to FALSE */
HalLedStatusControl.sleepActive = FALSE;
}
@ -109,7 +111,7 @@ uint8_t HalLedSet(uint8_t leds, uint8_t mode)
case HAL_LED_MODE_OFF:
case HAL_LED_MODE_TOGGLE:
{
led = HAL_LED_R;
led = HAL_LED_1;
leds &= HAL_LED_ALL;
sts = HalLedStatusControl.HalLedControlTable;
while(leds)
@ -160,7 +162,7 @@ void HalLedBlink(uint8_t leds, uint8_t numBlinks, uint8_t percent, uint16_t peri
{
if(percent < 100)
{
led = HAL_LED_R;
led = HAL_LED_1;
leds &= HAL_LED_ALL;
sts = HalLedStatusControl.HalLedControlTable;
while(leds)
@ -212,7 +214,7 @@ void HalLedUpdate(void)
HalLedControl_t *sts;
next = 0;
led = HAL_LED_R;
led = HAL_LED_1;
leds = HAL_LED_ALL;
sts = HalLedStatusControl.HalLedControlTable;
@ -299,48 +301,48 @@ void HalLedUpdate(void)
*/
void HalLedOnOff(uint8_t leds, uint8_t mode)
{
if(leds & HAL_LED_R)
if(leds & HAL_LED_1)
{
if(mode == HAL_LED_MODE_ON)
{
HAL_TURN_ON_LEDR();
HAL_TURN_ON_LED1();
}
else
{
HAL_TURN_OFF_LEDR();
HAL_TURN_OFF_LED1();
}
}
if(leds & HAL_LED_G)
if(leds & HAL_LED_2)
{
if(mode == HAL_LED_MODE_ON)
{
HAL_TURN_ON_LEDG();
HAL_TURN_ON_LED2();
}
else
{
HAL_TURN_OFF_LEDG();
HAL_TURN_OFF_LED2();
}
}
if(leds & HAL_LED_Y)
if(leds & HAL_LED_3)
{
if(mode == HAL_LED_MODE_ON)
{
HAL_TURN_ON_LEDY();
HAL_TURN_ON_LED3();
}
else
{
HAL_TURN_OFF_LEDY();
HAL_TURN_OFF_LED3();
}
}
if(leds & HAL_LED_BEEP)
if(leds & HAL_LED_4)
{
if(mode == HAL_LED_MODE_ON)
{
HAL_TURN_ON_BEEP();
HAL_TURN_ON_LED4();
}
else
{
HAL_TURN_OFF_BEEP();
HAL_TURN_OFF_LED4();
}
}
/* Remember current state */

View File

@ -1,3 +1,13 @@
/*
* @Author : stark1898y 1658608470@qq.com
* @Date : 2024-12-30 10:11:28
* @LastEditors : stark1898y 1658608470@qq.com
* @LastEditTime : 2025-03-27 10:11:40
* @FilePath : \BLE_TYQ_CH584M\HAL\MCU.c
* @Description :
*
* Copyright (c) 2025 by yzy, All Rights Reserved.
*/
/********************************** (C) COPYRIGHT *******************************
* File Name : MCU.c
* Author : WCH

View File

@ -2,11 +2,11 @@
* @Author : stark1898y 1658608470@qq.com
* @Date : 2024-12-30 10:11:28
* @LastEditors : stark1898y 1658608470@qq.com
* @LastEditTime : 2024-12-30 10:35:43
* @LastEditTime : 2025-03-27 10:11:52
* @FilePath : \BLE_TYQ_CH584M\HAL\RTC.c
* @Description :
*
* Copyright (c) 2024 by yzy, All Rights Reserved.
* Copyright (c) 2025 by yzy, All Rights Reserved.
*/
/********************************** (C) COPYRIGHT *******************************
* File Name : RTC.c

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,11 @@
/********************************** (C) COPYRIGHT ******************************
* File Name : CH58xBLE_LIB.H
* Author : WCH
* Version : v1.20
* Date : 2024/04/10
* Version : v1.30
* Date : 2025/02/07
* Description : head file(ch585/ch584)
* Copyright (c) 2023 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
@ -153,7 +153,7 @@ typedef struct
/*********************************************************************
* GLOBAL MACROS
*/
#define VER_FILE "CH585_BLE_LIB_V1.2"
#define VER_FILE "CH585_BLE_LIB_V1.3"
extern const uint8_t VER_LIB[]; // LIB version
#define SYSTEM_TIME_MICROSEN 625 // unit of process event timer is 625us
#define MS1_TO_SYSTEM_TIME(x) ((x)*1000/SYSTEM_TIME_MICROSEN) // transform unit in ms to unit in 625us ( attentional bias )
@ -419,7 +419,7 @@ extern const uint8_t VER_LIB[]; // LIB version
#define NAV_UUID 0x2A68 // Navigation
#define POS_QUALITY_UUID 0x2A69 // Position Quality
#define LN_FEATURE_UUID 0x2A6A // LN Feature
#define LN_CTRL_PT_UUID 0x2A6B // LN Control Point
#define LN_CTRL_PT_UUID 0x2A6B // LN Control Point
#define ELE_UUID 0x2A6C // Elevation
#define PRESSURE_UUID 0x2A6D // Pressure
#define TEMP_UUID 0x2A6E // Temperature
@ -526,7 +526,7 @@ extern const uint8_t VER_LIB[]; // LIB version
/************************************ATT***************************************/
#define ATT_MTU_SIZE 23 //!< Minimum ATT MTU size
#define ATT_MAX_MTU_SIZE 512 //!< Maximum ATT MTU size
// ATT Methods
// ATT Methods
#define ATT_ERROR_RSP 0x01 //!< ATT Error Response
#define ATT_EXCHANGE_MTU_REQ 0x02 //!< ATT Exchange MTU Request
#define ATT_EXCHANGE_MTU_RSP 0x03 //!< ATT Exchange MTU Response
@ -1523,7 +1523,7 @@ typedef struct
* All subsequent ATT Requests and Indications received by the local ATT Server
* and Client respectively will be dropped.
*
* This message is to inform the app (that has registered with GAP by calling
* This message is to inform the app (that has registered with GAP by calling
* GAP_RegisterForMsgs()) in case it wants to drop the connection.
*/
typedef struct
@ -1537,7 +1537,7 @@ typedef struct
* by the local ATT Server or Client when the ATT MTU size is updated for a
* connection. The default ATT MTU size is 23 octets.
*
* This message is to inform the app (that has registered with GAP by calling
* This message is to inform the app (that has registered with GAP by calling
* GAP_RegisterForMsgs()) about the new ATT MTU size negotiated for a connection.
*/
typedef struct
@ -1730,8 +1730,8 @@ typedef struct
* - Read Request: ATT_READ_REQ
* - Read Blob Request: ATT_READ_BLOB_REQ
*
* @note If blePending is returned then it's the responsibility of the application to respond to
* ATT_READ_REQ and ATT_READ_BLOB_REQ message with ATT_READ_RSP and ATT_READ_BLOB_RSP
* @note If blePending is returned then it's the responsibility of the application to respond to
* ATT_READ_REQ and ATT_READ_BLOB_REQ message with ATT_READ_RSP and ATT_READ_BLOB_RSP
* message respectively.
*
* @note Payload 'pValue' used with ATT_READ_RSP and ATT_READ_BLOB_RSP must be allocated using GATT_bm_alloc().
@ -1750,7 +1750,7 @@ typedef struct
*/
typedef uint8_t (*pfnGATTReadAttrCB_t)( uint16_t connHandle, gattAttribute_t *pAttr, uint8_t *pValue,
uint16_t *pLen, uint16_t offset, uint16_t maxLen, uint8_t method );
/**
* @brief Callback function prototype to write an attribute value.
*
@ -1761,7 +1761,7 @@ typedef uint8_t (*pfnGATTReadAttrCB_t)( uint16_t connHandle, gattAttribute_t *pA
* - Write Long: ATT_EXECUTE_WRITE_REQ
* - Reliable Writes: Multiple ATT_PREPARE_WRITE_REQ followed by one final ATT_EXECUTE_WRITE_REQ
*
* @note If blePending is returned then it's the responsibility of the application to 1) respond to
* @note If blePending is returned then it's the responsibility of the application to 1) respond to
* ATT_WRITE_REQ and ATT_EXECUTE_WRITE_REQ message with ATT_WRITE_RSP and ATT_EXECUTE_WRITE_RSP
* message respectively, and 2) free each request payload 'pValue' using BM_free().
*
@ -1780,7 +1780,7 @@ typedef uint8_t (*pfnGATTReadAttrCB_t)( uint16_t connHandle, gattAttribute_t *pA
*/
typedef uint8_t (*pfnGATTWriteAttrCB_t)( uint16_t connHandle, gattAttribute_t *pAttr, uint8_t *pValue,
uint16_t len, uint16_t offset, uint8_t method );
/**
* @brief Callback function prototype to authorize a Read or Write operation
* on a given attribute.
@ -2352,6 +2352,8 @@ typedef int (*pfnEcc_alg_f5_t)( uint8_t *w, uint8_t *n1, uint8_t *n2,
typedef int (*pfnEcc_alg_f6_t)( uint8_t *w, uint8_t *n1, uint8_t *n2, uint8_t *r,
uint8_t *iocap, uint8_t a1t, uint8_t *a1, uint8_t a2t, uint8_t *a2, uint8_t *check );
typedef void (*pfnSm_randkey_t)( uint8_t *randkey, uint8_t keylen );
/**
* Callback Registration Structure
*/
@ -2363,6 +2365,7 @@ typedef struct
pfnEcc_alg_g2_t alg_g2; //!< LE Secure Connections numeric comparison value generation function g2
pfnEcc_alg_f5_t alg_f5; //!< LE Secure Connect ions key generation function f5
pfnEcc_alg_f6_t alg_f6; //!< LE Secure Connections check value generation function f6
pfnSm_randkey_t randkey;
} gapEccCBs_t;
/**
@ -2632,7 +2635,7 @@ typedef struct
#define TX_MODE_TX_TIMEOUT TX_MODE_TX_FAIL //!< time of data transmission
#define TX_MODE_RX_DATA 0x02 //!< auto tx mode receive data(ack) and enter idle state
#define TX_MODE_RX_TIMEOUT 0x12 //!< auto tx mode receive timeout and enter idle state
#define TX_MODE_HOP_SHUT 0x22
#define TX_MODE_HOP_SHUT 0x22
// RX_MODE call RF_Rx
#define RX_MODE_RX_DATA 0x03 //!< basic or auto rx mode receive data
@ -2642,7 +2645,7 @@ typedef struct
#define RX_MODE_TX_FINISH 0x04 //!< auto rx mode sends data(ack) successfully and enters idle state
#define RX_MODE_TX_FAIL 0x14 //!< auto rx mode fail to send data and enter idle state
#define RX_MODE_TX_TIMEOUT RX_MODE_TX_FAIL //!< time of data transmission
#define RX_MODE_HOP_SHUT 0x24
#define RX_MODE_HOP_SHUT 0x24
// LLE_MODE_TYPE
#define LLE_MODE_BASIC (0) //!< basic mode, enter idle state after sending or receive
@ -2963,7 +2966,7 @@ extern bStatus_t LL_Decrypt( uint8_t *key, uint8_t *plaintextData, uint8_t *decr
*
* @param handle - connect handle
*
* @return 0xFFFFFFFF-handle error,number of packets not receiving ack
* @return 0xFFFFFFFF-handle error,number of packets not receiving ack
*/
extern uint32_t LL_GetNumberOfUnAckPacket( uint16_t handle );
@ -3015,7 +3018,7 @@ extern int16_t BLE_ReadCfo( void );
/**
* @brief pa control init
*
*
* @note Can't be called until role Init
*
* @param paControl - pa control parameters(global variable)
@ -3025,9 +3028,9 @@ extern int16_t BLE_ReadCfo( void );
extern void BLE_PAControlInit( blePaControlConfig_t *paControl );
/**
* @brief ble register reset and rf calibration
* @brief ble register reset and rf calibration
*
* @param None
* @param None
*
* @return None
*/
@ -3067,7 +3070,7 @@ extern void LLE_IRQLibHandler( void );
*
* @return access address
* the Access Address meets the following requirements:
* It shall have no more than six consecutive zeros or ones.
* It shall have no more than six consecutive zeros or ones.
* It shall not be t he advertising channel packets¡¯ Access Address.
* It shall not be a sequence that differ s from the advertising channel packets' Access Address by only one bit.
* It shall not have all four octets equal.
@ -3084,7 +3087,7 @@ extern uint8_t linkDB_Register( pfnLinkDBCB_t pFunc );
/*
* linkDB_State - Check to see if a physical link is in a specific state.
*
*
* returns TRUE is the link is in state. FALSE, otherwise.
*/
extern uint8_t linkDB_State( uint16_t connectionHandle, uint8_t state );
@ -3151,13 +3154,13 @@ extern void GATT_RegisterForInd( uint8_t taskId );
*
* @param handle - handle to look for
* @param pHandle - handle of owner of attribute (to be returned)
*
*
* @return Pointer to attribute record. NULL, otherwise.
*/
extern gattAttribute_t *GATT_FindHandle( uint16_t handle, uint16_t *pHandle );
/**
* @brief This sub-procedure is used when a server is configured to
* @brief This sub-procedure is used when a server is configured to
* indicate a characteristic value to a client and expects an
* attribute protocol layer acknowledgement that the indication
* was successfully received.
@ -3186,9 +3189,9 @@ extern gattAttribute_t *GATT_FindHandle( uint16_t handle, uint16_t *pHandle );
*/
extern bStatus_t GATT_Indication( uint16_t connHandle, attHandleValueInd_t *pInd, uint8_t authenticated, uint8_t taskId );
/**
* @brief This sub-procedure is used when a server is configured to
* @brief This sub-procedure is used when a server is configured to
* notify a characteristic value to a client without expecting
* any attribute protocol layer acknowledgement that the
* any attribute protocol layer acknowledgement that the
* notification was successfully received.
*
* The ATT Handle Value Notification is used in this sub-procedure.
@ -3243,7 +3246,7 @@ extern bStatus_t GATT_Notification( uint16_t connHandle, attHandleValueNoti_t *p
extern bStatus_t GATT_ExchangeMTU( uint16_t connHandle, attExchangeMTUReq_t *pReq, uint8_t taskId );
/**
* @brief This sub-procedure is used by a client to discover all
* @brief This sub-procedure is used by a client to discover all
* the primary services on a server.
*
* The ATT Read By Group Type Request is used with the Attribute
@ -3276,7 +3279,7 @@ extern bStatus_t GATT_DiscAllPrimaryServices( uint16_t connHandle, uint8_t taskI
/**
* @brief This sub-procedure is used by a client to discover a specific
* primary service on a server when only the Service UUID is
* known. The primary specific service may exist multiple times
* known. The primary specific service may exist multiple times
* on a server. The primary service being discovered is identified
* by the service UUID.
*
@ -3312,7 +3315,7 @@ extern bStatus_t GATT_DiscPrimaryServiceByUUID( uint16_t connHandle, uint8_t *pU
/**
* @brief This sub-procedure is used by a client to find include
* service declarations within a service definition on a
* service declarations within a service definition on a
* server. The service specified is identified by the service
* handle range.
*
@ -3347,7 +3350,7 @@ extern bStatus_t GATT_DiscPrimaryServiceByUUID( uint16_t connHandle, uint8_t *pU
extern bStatus_t GATT_FindIncludedServices( uint16_t connHandle, uint16_t startHandle, uint16_t endHandle, uint8_t taskId );
/**
* @brief This sub-procedure is used by a client to find all the
* @brief This sub-procedure is used by a client to find all the
* characteristic declarations within a service definition on
* a server when only the service handle range is known. The
* service specified is identified by the service handle range.
@ -3383,11 +3386,11 @@ extern bStatus_t GATT_FindIncludedServices( uint16_t connHandle, uint16_t startH
extern bStatus_t GATT_DiscAllChars( uint16_t connHandle, uint16_t startHandle, uint16_t endHandle, uint8_t taskId );
/**
* @brief This sub-procedure is used by a client to discover service
* characteristics on a server when only the service handle
* ranges are known and the characteristic UUID is known.
* @brief This sub-procedure is used by a client to discover service
* characteristics on a server when only the service handle
* ranges are known and the characteristic UUID is known.
* The specific service may exist multiple times on a server.
* The characteristic being discovered is identified by the
* The characteristic being discovered is identified by the
* characteristic UUID.
*
* The ATT Read By Type Request is used with the Attribute Type
@ -3419,10 +3422,10 @@ extern bStatus_t GATT_DiscAllChars( uint16_t connHandle, uint16_t startHandle, u
extern bStatus_t GATT_DiscCharsByUUID( uint16_t connHandle, attReadByTypeReq_t *pReq, uint8_t taskId );
/**
* @brief This sub-procedure is used by a client to find all the
* @brief This sub-procedure is used by a client to find all the
* characteristic descriptors Attribute Handles and Attribute
* Types within a characteristic definition when only the
* characteristic handle range is known. The characteristic
* Types within a characteristic definition when only the
* characteristic handle range is known. The characteristic
* specified is identified by the characteristic handle range.
*
* The ATT Find Information Request is used with the Starting
@ -3458,12 +3461,12 @@ extern bStatus_t GATT_DiscAllCharDescs( uint16_t connHandle, uint16_t startHandl
* @brief This sub-procedure is used to read a Characteristic Value
* from a server when the client knows the Characteristic Value
* Handle. The ATT Read Request is used with the Attribute Handle
* parameter set to the Characteristic Value Handle. The Read
* parameter set to the Characteristic Value Handle. The Read
* Response returns the Characteristic Value in the Attribute
* Value parameter.
*
* The Read Response only contains a Characteristic Value that
* is less than or equal to (ATT_MTU ?1) octets in length. If
* is less than or equal to (ATT_MTU ?1) octets in length. If
* the Characteristic Value is greater than (ATT_MTU - 1) octets
* in length, the Read Long Characteristic Value procedure may
* be used if the rest of the Characteristic Value is required.
@ -3500,7 +3503,7 @@ extern bStatus_t GATT_ReadCharValue( uint16_t connHandle, attReadReq_t *pReq, ui
* The Attribute Type is set to the known characteristic UUID and
* the Starting Handle and Ending Handle parameters shall be set
* to the range over which this read is to be performed. This is
* typically the handle range for the service in which the
* typically the handle range for the service in which the
* characteristic belongs.
*
* If the return status from this function is SUCCESS, the calling
@ -3529,7 +3532,7 @@ extern bStatus_t GATT_ReadUsingCharUUID( uint16_t connHandle, attReadByTypeReq_t
/**
* @brief This sub-procedure is used to read a Characteristic Value from
* a server when the client knows the Characteristic Value Handle
* and the length of the Characteristic Value is longer than can
* and the length of the Characteristic Value is longer than can
* be sent in a single Read Response Attribute Protocol message.
*
* The ATT Read Blob Request is used in this sub-procedure.
@ -3559,8 +3562,8 @@ extern bStatus_t GATT_ReadLongCharValue( uint16_t connHandle, attReadBlobReq_t *
/**
* @brief This sub-procedure is used to read multiple Characteristic Values
* from a server when the client knows the Characteristic Value
* Handles. The Attribute Protocol Read Multiple Requests is used
* from a server when the client knows the Characteristic Value
* Handles. The Attribute Protocol Read Multiple Requests is used
* with the Set Of Handles parameter set to the Characteristic Value
* Handles. The Read Multiple Response returns the Characteristic
* Values in the Set Of Values parameter.
@ -3599,16 +3602,16 @@ extern bStatus_t GATT_ReadMultiCharValues( uint16_t connHandle, attReadMultiReq_
* Value. This sub-procedure can not be used to write a long
* characteristic; instead the Write Long Characteristic Values
* sub-procedure should be used.
*
*
* The ATT Write Command is used for this sub-procedure. The
* Attribute Handle parameter shall be set to the Characteristic
* Value Handle. The Attribute Value parameter shall be set to
* the new Characteristic Value.
*
* No response will be sent to the calling application task for this
* sub-procedure. If the Characteristic Value write request is the
* wrong size, or has an invalid value as defined by the profile,
* then the write will not succeed and no error will be generated
* sub-procedure. If the Characteristic Value write request is the
* wrong size, or has an invalid value as defined by the profile,
* then the write will not succeed and no error will be generated
* by the server.
*
* @param connHandle - connection to use
@ -3625,25 +3628,25 @@ extern bStatus_t GATT_WriteNoRsp( uint16_t connHandle, attWriteReq_t *pReq );
/**
* @brief This sub-procedure is used to write a Characteristic Value
* to a server when the client knows the Characteristic Value
* to a server when the client knows the Characteristic Value
* Handle and the ATT Bearer is not encrypted. This sub-procedure
* shall only be used if the Characteristic Properties authenticated
* bit is enabled and the client and server device share a bond as
* defined in the GAP.
*
* This sub-procedure only writes the first (ATT_MTU ?15) octets
* of an Attribute Value. This sub-procedure cannot be used to
* of an Attribute Value. This sub-procedure cannot be used to
* write a long Attribute.
*
* The ATT Write Command is used for this sub-procedure. The
* Attribute Handle parameter shall be set to the Characteristic
* Value Handle. The Attribute Value parameter shall be set to
* Value Handle. The Attribute Value parameter shall be set to
* the new Characteristic Value authenticated by signing the
* value, as defined in the Security Manager.
*
* No response will be sent to the calling application task for this
* sub-procedure. If the authenticated Characteristic Value that is
* written is the wrong size, or has an invalid value as defined by
* sub-procedure. If the authenticated Characteristic Value that is
* written is the wrong size, or has an invalid value as defined by
* the profile, or the signed value does not authenticate the client,
* then the write will not succeed and no error will be generated by
* the server.
@ -3666,10 +3669,10 @@ extern bStatus_t GATT_SignedWriteNoRsp( uint16_t connHandle, attWriteReq_t *pReq
* to a server when the client knows the characteristic value
* handle. This sub-procedure only writes the first (ATT_MTU-3)
* octets of a characteristic value. This sub-procedure can not
* be used to write a long attribute; instead the Write Long
* be used to write a long attribute; instead the Write Long
* Characteristic Values sub-procedure should be used.
*
* The ATT Write Request is used in this sub-procedure. The
* The ATT Write Request is used in this sub-procedure. The
* Attribute Handle parameter shall be set to the Characteristic
* Value Handle. The Attribute Value parameter shall be set to
* the new characteristic.
@ -3700,7 +3703,7 @@ extern bStatus_t GATT_WriteCharValue( uint16_t connHandle, attWriteReq_t *pReq,
/**
* @brief This sub-procedure is used to write a Characteristic Value to
* a server when the client knows the Characteristic Value Handle
* but the length of the Characteristic Value is longer than can
* but the length of the Characteristic Value is longer than can
* be sent in a single Write Request Attribute Protocol message.
*
* The ATT Prepare Write Request and Execute Write Request are
@ -3739,11 +3742,11 @@ extern bStatus_t GATT_WriteLongCharValue( uint16_t connHandle, attPrepareWriteRe
* and assurance is required that the correct Characteristic Value
* is going to be written by transferring the Characteristic Value
* to be written in both directions before the write is performed.
* This sub-procedure can also be used when multiple values must
* This sub-procedure can also be used when multiple values must
* be written, in order, in a single operation.
*
* The sub-procedure has two phases, the first phase prepares the
* characteristic values to be written. Once this is complete,
* characteristic values to be written. Once this is complete,
* the second phase performs the execution of all of the prepared
* characteristic value writes on the server from this client.
*
@ -3787,7 +3790,7 @@ extern bStatus_t GATT_ReliableWrites( uint16_t connHandle, attPrepareWriteReq_t
* declaration's Attribute handle.
*
* The ATT Read Request is used for this sub-procedure. The Read
* Request is used with the Attribute Handle parameter set to the
* Request is used with the Attribute Handle parameter set to the
* characteristic descriptor handle. The Read Response returns the
* characteristic descriptor value in the Attribute Value parameter.
*
@ -3885,7 +3888,7 @@ extern bStatus_t GATT_WriteCharDesc( uint16_t connHandle, attWriteReq_t *pReq, u
/**
* @brief This sub-procedure is used to write a Characteristic Value to
* a server when the client knows the Characteristic Value Handle
* but the length of the Characteristic Value is longer than can
* but the length of the Characteristic Value is longer than can
* be sent in a single Write Request Attribute Protocol message.
*
* The ATT Prepare Write Request and Execute Write Request are
@ -4297,7 +4300,7 @@ extern bStatus_t GAPRole_TerminateLink( uint16_t connHandle );
* @param connHandle - connection handle
*
* @return bStatus_t: HCI Error Code.<BR>
*
*
*/
extern bStatus_t GAPRole_ReadRssiCmd( uint16_t connHandle );
@ -4773,7 +4776,7 @@ extern bStatus_t RF_SetFrequency( uint32_t frequency, uint8_t ch );
extern void RF_FrequencyHoppingShut( void );
/**
* @brief
* @brief
*
* @param resendCount - Maximum count of sending HOP_TX pdu,0 = unlimited.
*
@ -4782,7 +4785,7 @@ extern void RF_FrequencyHoppingShut( void );
extern uint8_t RF_FrequencyHoppingTx( uint8_t resendCount );
/**
* @brief
* @brief
*
* @param timeoutMS - Maximum time to wait for receiving HOP_TX pdu(Time = n * 1mSec),0 = unlimited.
*

View File

@ -1,8 +1,8 @@
/********************************** (C) COPYRIGHT ******************************
* File Name : CH58xBLE_ROM.H
* Author : WCH
* Version : v1.20
* Date : 2024/04/10
* Version : v1.30
* Date : 2025/02/07
* Description : head file(ch585/ch584)
* Address Space
* CODE: 00040000H - 0006FFFFH 192K
@ -155,7 +155,7 @@ typedef struct
/*********************************************************************
* GLOBAL MACROS
*/
#define VER_FILE "CH585_BLE_LIB_V1.2"
#define VER_FILE "CH585_BLE_LIB_V1.3"
extern const uint8_t VER_LIB[]; // LIB version
#define SYSTEM_TIME_MICROSEN 625 // unit of process event timer is 625us
#define MS1_TO_SYSTEM_TIME(x) ((x)*1000/SYSTEM_TIME_MICROSEN) // transform unit in ms to unit in 625us ( attentional bias )
@ -2354,6 +2354,8 @@ typedef int (*pfnEcc_alg_f5_t)( uint8_t *w, uint8_t *n1, uint8_t *n2,
typedef int (*pfnEcc_alg_f6_t)( uint8_t *w, uint8_t *n1, uint8_t *n2, uint8_t *r,
uint8_t *iocap, uint8_t a1t, uint8_t *a1, uint8_t a2t, uint8_t *a2, uint8_t *check );
typedef void (*pfnSm_randkey_t)( uint8_t *randkey, uint8_t keylen );
/**
* Callback Registration Structure
*/
@ -2365,6 +2367,7 @@ typedef struct
pfnEcc_alg_g2_t alg_g2; //!< LE Secure Connections numeric comparison value generation function g2
pfnEcc_alg_f5_t alg_f5; //!< LE Secure Connect ions key generation function f5
pfnEcc_alg_f6_t alg_f6; //!< LE Secure Connections check value generation function f6
pfnSm_randkey_t randkey;
} gapEccCBs_t;
/**

Binary file not shown.

Binary file not shown.

View File

@ -187,7 +187,7 @@ typedef struct
uint8_t devType; //!< reserved
uint16_t timeout; //!< Connection communication timeout period (in about 1 ms)
uint8_t OwnInfo[6]; //!< Local Information
uint8_t PeerInfo[6]; //!< Peer information
uint8_t PeerInfo[6]; //!< resv
pfnRfRoleBoundCB rfBoundCB;
uint32_t ChannelMap; //!< indicating Used and Unused data channels.Every channel is represented with a
//!< bit positioned as per the data channel index,The LSB represents data channel index 0

View File

@ -1,13 +1,3 @@
/*
* @Author : stark1898y 1658608470@qq.com
* @Date : 2024-12-30 10:28:39
* @LastEditors : stark1898y 1658608470@qq.com
* @LastEditTime : 2024-12-30 10:40:14
* @FilePath : \BLE_TYQ_CH584M\RVMSIS\core_riscv.h
* @Description :
*
* Copyright (c) 2024 by yzy, All Rights Reserved.
*/
/********************************** (C) COPYRIGHT *******************************
* File Name : core_riscv.h
* Author : WCH
@ -16,7 +6,7 @@
* Description : CH585 Series RISC-V Core Peripheral Access Layer Header File
*********************************************************************************
* Copyright (c) 2024 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef __CORE_RISCV_H__

View File

@ -201,11 +201,11 @@ __highcode_init:
addi a0, a0, 4
bltu a0, a1, 1b
2:
/* 用户模式中断使能 */
/*预取使能*/
/* User Mode Interrupt Enable */
/*Prefetch Enable*/
li t0, 0x25
csrw 0xbc0, t0
/* 打开嵌套中断、硬件压栈功能 */
/* Enable Nested Interrupts and Hardware Stacking Function */
li t0, 0x3
csrw 0x804, t0
li t0, 0x1
@ -215,7 +215,7 @@ __highcode_init:
csrw mstatus, t0
la t0, _vector_base
/* 配置向量表模式为绝对地址模式 */
/* Configure the Vector Table Mode to Absolute Address Mode */
ori t0, t0, 3
csrw mtvec, t0

View File

@ -247,7 +247,7 @@ int adc_to_temperature_celsius(uint16_t adc_val)
uint32_t C25 = 0;
int temp;
C25 = (*((PUINT32)ROM_CFG_TMP_25C));
C25 = (*((uint32_t*)ROM_CFG_TMP_25C));
/* current temperature = standard temperature + (adc deviation * adc linearity coefficient) */
temp = (((C25 >> 16) & 0xFFFF) ? ((C25 >> 16) & 0xFFFF) : 25) + \

View File

@ -200,13 +200,13 @@ void LSECFG_Capacitance(LSECapTypeDef c)
*/
void Calibration_LSI(Cali_LevelTypeDef cali_Lv)
{
UINT64 i;
uint64_t i;
long long cnt_offset;
UINT8 retry = 0;
UINT8 retry_all = 0;
INT32 freq_sys;
UINT32 cnt_32k = 0;
UINT32 irqv = 0;
uint8_t retry = 0;
uint8_t retry_all = 0;
int32_t freq_sys;
uint32_t cnt_32k = 0;
uint32_t irqv = 0;
freq_sys = GetSysClock();

View File

@ -29,8 +29,8 @@
*
* @return none
*/
void I2C_Init(I2C_ModeTypeDef I2C_Mode, UINT32 I2C_ClockSpeed, I2C_DutyTypeDef I2C_DutyCycle,
I2C_AckTypeDef I2C_Ack, I2C_AckAddrTypeDef I2C_AckAddr, UINT16 I2C_OwnAddress1)
void I2C_Init(I2C_ModeTypeDef I2C_Mode, uint32_t I2C_ClockSpeed, I2C_DutyTypeDef I2C_DutyCycle,
I2C_AckTypeDef I2C_Ack, I2C_AckAddrTypeDef I2C_AckAddr, uint16_t I2C_OwnAddress1)
{
uint32_t sysClock;
uint16_t tmpreg;

View File

@ -276,8 +276,14 @@ void LowPower_Idle(void)
__HIGH_CODE
void LowPower_Halt(void)
{
uint32_t i;
uint8_t x32Mpw;
uint16_t clk_sys_cfg;
uint8_t flash_cfg,flash_sck;
clk_sys_cfg = R16_CLK_SYS_CFG;
flash_cfg = R8_FLASH_CFG;
flash_sck = R8_FLASH_SCK;
FLASH_ROM_SW_RESET();
R8_FLASH_CTRL = 0x04; //flash关闭
x32Mpw = R8_XT32M_TUNE;
@ -292,17 +298,51 @@ void LowPower_Halt(void)
sys_safe_access_enable();
R8_XT32M_TUNE = x32Mpw;
sys_safe_access_disable();
sys_safe_access_enable();
R8_PLL_CONFIG |= (1 << 5);
sys_safe_access_disable();
// sys_safe_access_enable();
// R8_PLL_CONFIG |= (1 << 5);
// sys_safe_access_disable();
if(R16_CLK_SYS_CFG & RB_OSC32M_SEL) //使用外部32M
{
sys_safe_access_enable();
R8_SLP_POWER_CTRL |= 0x40;
R8_FLASH_CFG = 0X57;
R8_FLASH_SCK = R8_FLASH_SCK & (~(1<<4));
R16_CLK_SYS_CFG = CLK_SOURCE_HSE_8MHz;
sys_safe_access_disable();
}
else//使用内部16M
{
sys_safe_access_enable();
R8_FLASH_CFG = 0X57;
R8_FLASH_SCK = R8_FLASH_SCK & (~(1<<4));
R16_CLK_SYS_CFG = CLK_SOURCE_HSI_4MHz;
sys_safe_access_disable();
}
PFIC->SCTLR |= (1 << 2); //deep sleep
__WFI();
__nop();
__nop();
if((!(clk_sys_cfg & RB_OSC32M_SEL)) && (clk_sys_cfg & 0x100)) //使用内部16M
{
i = 40;
do
{
__nop();
}while(--i);
}
sys_safe_access_enable();
R8_PLL_CONFIG &= ~(1 << 5);
R8_FLASH_CFG = flash_cfg;
R8_FLASH_SCK = flash_sck;
R16_CLK_SYS_CFG = clk_sys_cfg;
sys_safe_access_disable();
// sys_safe_access_enable();
// R8_PLL_CONFIG &= ~(1 << 5);
// sys_safe_access_disable();
}
/*******************************************************************************
@ -319,18 +359,19 @@ void LowPower_Halt(void)
__HIGH_CODE
void LowPower_Sleep(uint16_t rm)
{
__attribute__((aligned(4))) uint8_t MacAddr[6] = {0};
uint8_t x32Mpw;
uint16_t power_plan;
uint16_t clk_sys_cfg;
uint16_t hfck_pwr_ctrl;
GetMACAddress(MacAddr);
uint8_t flash_cfg,flash_sck;
uint32_t i;
clk_sys_cfg = R16_CLK_SYS_CFG;
hfck_pwr_ctrl = R8_HFCK_PWR_CTRL;
x32Mpw = R8_XT32M_TUNE;
x32Mpw = (x32Mpw & 0xfc) | 0x03; // 150%额定电流
flash_cfg = R8_FLASH_CFG;
flash_sck = R8_FLASH_SCK;
sys_safe_access_enable();
R8_BAT_DET_CTRL = 0; // 关闭电压监控
@ -339,33 +380,40 @@ void LowPower_Sleep(uint16_t rm)
R8_XT32M_TUNE = x32Mpw;
sys_safe_access_disable();
sys_safe_access_enable();
R16_POWER_PLAN &= ~RB_XT_PRE_EN;
sys_safe_access_disable();
PFIC->SCTLR |= (1 << 2); //deep sleep
power_plan = R16_POWER_PLAN & (RB_PWR_DCDC_EN | RB_PWR_DCDC_PRE);
power_plan |= RB_PWR_PLAN_EN | RB_PWR_CORE | rm | (2<<11);
power_plan &= ~RB_XT_PRE_EN;
sys_safe_access_enable();
if(rm & RB_XT_PRE_EN)
{
R8_SLP_POWER_CTRL |= 0x41;
}
else
{
R8_SLP_POWER_CTRL |= 0x40;
}
R16_POWER_PLAN = power_plan;
R8_HFCK_PWR_CTRL |= RB_CLK_RC16M_PON; //睡眠需要打开内部HSI之后睡
R8_HFCK_PWR_CTRL |= RB_CLK_RC16M_PON; //睡眠需要打开内部HSI
sys_safe_access_disable();
if((R16_CLK_SYS_CFG & RB_CLK_SYS_MOD) == 0x40)
if(R16_CLK_SYS_CFG & RB_OSC32M_SEL) //使用外部32M
{
sys_safe_access_enable();
R16_CLK_SYS_CFG = (R16_CLK_SYS_CFG&(~RB_CLK_PLL_DIV))|24;
if(rm & RB_XT_PRE_EN)
{
R8_SLP_POWER_CTRL |= 0x40;
}
else
{
R8_SLP_POWER_CTRL |= 0x41;
}
R8_FLASH_CFG = 0X57;
R8_FLASH_SCK = R8_FLASH_SCK & (~(1<<4));
R16_CLK_SYS_CFG = CLK_SOURCE_HSE_4MHz;
sys_safe_access_disable();
}
else//使用内部16M
{
sys_safe_access_enable();
R8_FLASH_CFG = 0X57;
R8_FLASH_SCK = R8_FLASH_SCK & (~(1<<4));
R16_CLK_SYS_CFG = CLK_SOURCE_HSI_4MHz;
sys_safe_access_disable();
}
// sys_safe_access_enable();
// R8_PLL_CONFIG |= (1 << 5);
// sys_safe_access_disable();
@ -374,7 +422,18 @@ void LowPower_Sleep(uint16_t rm)
__nop();
__nop();
if((!(clk_sys_cfg & RB_OSC32M_SEL)) && (clk_sys_cfg & 0x100)) //使用内部16M
{
i = 40;
do
{
__nop();
}while(--i);
}
sys_safe_access_enable();
R8_FLASH_CFG = flash_cfg;
R8_FLASH_SCK = flash_sck;
R16_CLK_SYS_CFG = clk_sys_cfg;
R8_HFCK_PWR_CTRL = hfck_pwr_ctrl;
sys_safe_access_disable();
@ -382,14 +441,10 @@ void LowPower_Sleep(uint16_t rm)
R16_POWER_PLAN &= ~RB_PWR_PLAN_EN;
sys_safe_access_disable();
sys_safe_access_enable();
R16_POWER_PLAN &= ~RB_XT_PRE_EN;
sys_safe_access_disable();
// sys_safe_access_enable();
// R8_PLL_CONFIG &= ~(1 << 5);
// sys_safe_access_disable();
DelayUs(40);
// DelayUs(40);
}
/*********************************************************************
@ -409,20 +464,18 @@ void LowPower_Sleep(uint16_t rm)
__HIGH_CODE
void LowPower_Shutdown(uint16_t rm)
{
uint8_t x32Kpw, x32Mpw;
uint8_t x32Kpw;
FLASH_ROM_SW_RESET();
x32Kpw = R8_XT32K_TUNE;
x32Mpw = R8_XT32M_TUNE;
x32Mpw = (x32Mpw & 0xfc) | 0x03; // 150%额定电流
x32Kpw = (x32Kpw & 0xfc) | 0x01; // LSE驱动电流降低到额定电流
SetSysClock(CLK_SOURCE_HSI_PLL_13MHz);
sys_safe_access_enable();
R8_BAT_DET_CTRL = 0; // 关闭电压监控
sys_safe_access_disable();
sys_safe_access_enable();
R8_XT32K_TUNE = x32Kpw;
R8_XT32M_TUNE = x32Mpw;
sys_safe_access_disable();
PFIC->SCTLR |= (1 << 2); //deep sleep

View File

@ -98,7 +98,8 @@ void SPI0_DataMode(ModeBitOrderTypeDef m)
void SPI0_MasterSendByte(uint8_t d)
{
R8_SPI0_CTRL_MOD &= ~RB_SPI_FIFO_DIR;
R8_SPI0_BUFFER = d;
R16_SPI0_TOTAL_CNT = 1; // 设置要发送的数据长度
R8_SPI0_FIFO = d;
while(!(R8_SPI0_INT_FLAG & RB_SPI_FREE));
}
@ -262,6 +263,7 @@ uint8_t SPI0_SlaveRecvByte(void)
void SPI0_SlaveSendByte(uint8_t d)
{
R8_SPI0_CTRL_MOD &= ~RB_SPI_FIFO_DIR;
R16_SPI0_TOTAL_CNT = 1;
R8_SPI0_FIFO = d;
while(R8_SPI0_FIFO_COUNT != 0); // 等待发送完成
}

View File

@ -97,7 +97,8 @@ void SPI1_DataMode(ModeBitOrderTypeDef m)
void SPI1_MasterSendByte(uint8_t d)
{
R8_SPI1_CTRL_MOD &= ~RB_SPI_FIFO_DIR;
R8_SPI1_BUFFER = d;
R16_SPI1_TOTAL_CNT = 1; // 设置要发送的数据长度
R8_SPI1_FIFO = d;
while(!(R8_SPI1_INT_FLAG & RB_SPI_FREE));
}
@ -112,7 +113,7 @@ void SPI1_MasterSendByte(uint8_t d)
*/
uint8_t SPI1_MasterRecvByte(void)
{
R8_SPI1_CTRL_MOD &= ~RB_SPI_FIFO_DIR;
R8_SPI1_CTRL_MOD |= RB_SPI_FIFO_DIR; // 设置数据方向为输入
R8_SPI1_BUFFER = 0xFF; // 启动传输
while(!(R8_SPI1_INT_FLAG & RB_SPI_FREE));
return (R8_SPI1_BUFFER);

View File

@ -83,8 +83,8 @@ void SetSysClock(SYS_CLKTypeDef sc)
}
else
{
R8_FLASH_SCK = R8_FLASH_SCK|(1<<4);
R8_FLASH_CFG = 0X03;
R8_FLASH_SCK = R8_FLASH_SCK & (~(1<<4));
R8_FLASH_CFG = 0X07;
}
}
else
@ -136,12 +136,14 @@ void highcode_init(void)
R32_SAFE_MODE_CTRL |= RB_XROM_312M_SEL;
R8_SAFE_MODE_CTRL &= ~RB_SAFE_AUTO_EN;
sys_safe_access_enable();
R32_MISC_CTRL |= 5; //
R32_MISC_CTRL |= 5|(3<<25); //
R8_PLL_CONFIG &= ~(1 << 5); //
R8_HFCK_PWR_CTRL |= RB_CLK_RC16M_PON | RB_CLK_PLL_PON;
R16_CLK_SYS_CFG = CLK_SOURCE_HSI_PLL_62_4MHz;
R8_FLASH_SCK = R8_FLASH_SCK & (~(1<<4));
R8_FLASH_CFG = 0X02;
R8_XT32M_TUNE = (R8_XT32M_TUNE&(~0x03))|0x01;
R8_CK32K_CONFIG |= RB_CLK_INT32K_PON;
R8_SAFE_MODE_CTRL |= RB_SAFE_AUTO_EN;
sys_safe_access_disable();
}
@ -213,6 +215,8 @@ void MachineMode_Call(MachineMode_Call_func func)
PFIC_DisableIRQ(SWI_IRQn);
_vector_base[SWI_IRQn] = sw_irqtable;
// if(i != 4)
// {
// /* »Ö¸´Ô­±¾µÄSWÃâ±íÖÐ¶Ï */
@ -335,6 +339,7 @@ void SYS_ResetExecute(void)
*
* @return none
*/
__HIGH_CODE
void SYS_DisableAllIrq(uint32_t *pirqv)
{
*pirqv = (PFIC->ISR[0] >> 8) | (PFIC->ISR[1] << 24);
@ -351,6 +356,7 @@ void SYS_DisableAllIrq(uint32_t *pirqv)
*
* @return none
*/
__HIGH_CODE
void SYS_RecoverIrq(uint32_t irq_status)
{
PFIC->IENR[0] = (irq_status << 8);
@ -568,8 +574,6 @@ int _write(int fd, char *buf, int size)
#endif
// https://www.cnblogs.com/debugdabiaoge/p/18543792
/*********************************************************************
* @fn _sbrk
*

View File

@ -285,7 +285,7 @@ extern "C" {
//( (( RB_CLK_SYS_MOD[0] ? Fpll_div2 : (RB_OSC32M_SEL ? Fck32m : Fck16m) ) / RB_CLK_PLL_DIV
// default: Fsys = Fck16m/ RB_CLK_PLL_DIV = 16MHz / 3 = 5.33MHz
// range: 32KHz, 1MHz~32MHz, 9.75MHz78MHz
// range: 32KHz, 1MHz~32MHz, 9.75MHz~78MHz
/* System: sleep control register */
#define R32_SLEEP_CONTROL (*((PUINT32V)0x4000100C)) // RWA, sleep control, SAM
@ -392,7 +392,7 @@ extern "C" {
#define RB_PWR_LDO_EN 0x0100 // RWA, LDO enable
#define RB_PWR_DCDC_EN 0x0200 // RWA, DC/DC converter enable: 0=DC/DC disable and bypass, 1=DC/DC enable
#define RB_PWR_DCDC_PRE 0x0400 // RWA, DC/DC converter pre-enable
#define RB_XT_PRE_CFG 0x1800 // RWA, extern 32MHz HSE early wake up time configuration
//#define RB_XT_PRE_CFG 0x1800 // RWA, extern 32MHz HSE early wake up time configuration
#define RB_PWR_MUST_0 0x2000 // RWA, must write 0
#define RB_XT_PRE_EN 0x4000 // RWA, extern 32MHz HSE early wake up enable, must be used with LSI/LSE
#define RB_PWR_PLAN_EN 0x8000 // RWA/WZ, power plan enable, auto clear after sleep executed
@ -486,7 +486,7 @@ extern "C" {
/* System: ADC and Touch-key register */
#define R32_ADC_CTRL (*((PUINT32V)0x40001058)) // RW, ADC control
#define R8_ADC_CHANNEL (*((PUINT8V)0x40001058)) // RW, ADC input channel selection
#define RB_ADC_CH_INX 0x1F // RW, ADC input channel index, 00~0D=A0A13, 0E=VBAT, 0F=TS, 10=NFC energy check channel
#define RB_ADC_CH_INX 0x1F // RW, ADC input channel index, 00~0D=A0~13, 0E=VBAT, 0F=TS, 10=NFC energy check channel
#define R8_ADC_CFG (*((PUINT8V)0x40001059)) // RW, ADC configure
#define RB_ADC_POWER_ON 0x01 // RW, ADC power control: 0=power down, 1=power on
#define RB_ADC_BUF_EN 0x02 // RW, ADC input buffer enable

View File

@ -26,10 +26,10 @@ extern "C" {
*/
void FLASH_ROM_READ(uint32_t StartAddr, void *Buffer, uint32_t len);
UINT8 UserOptionByteConfig(FunctionalState RESET_EN, FunctionalState BOOT_PIN, FunctionalState UART_NO_KEY_EN,
uint8_t UserOptionByteConfig(FunctionalState RESET_EN, FunctionalState BOOT_PIN, FunctionalState UART_NO_KEY_EN,
uint32_t FLASHProt_Size);
UINT8 UserOptionByteClose_SWD(void);
uint8_t UserOptionByteClose_SWD(void);
void UserOptionByte_Active(void);

View File

@ -145,8 +145,8 @@ typedef enum
#define I2C_EVENT_SLAVE_BYTE_TRANSMITTING ((uint32_t)0x00060080) /* TRA, BUSY and TXE flags */
#define I2C_EVENT_SLAVE_ACK_FAILURE ((uint32_t)0x00000400) /* AF flag */
void I2C_Init(I2C_ModeTypeDef I2C_Mode, UINT32 I2C_ClockSpeed, I2C_DutyTypeDef I2C_DutyCycle,
I2C_AckTypeDef I2C_Ack, I2C_AckAddrTypeDef I2C_AckAddr, UINT16 I2C_OwnAddress1);
void I2C_Init(I2C_ModeTypeDef I2C_Mode, uint32_t I2C_ClockSpeed, I2C_DutyTypeDef I2C_DutyCycle,
I2C_AckTypeDef I2C_Ack, I2C_AckAddrTypeDef I2C_AckAddr, uint16_t I2C_OwnAddress1);
void I2C_Cmd(FunctionalState NewState);
void I2C_GenerateSTART(FunctionalState NewState);
void I2C_GenerateSTOP(FunctionalState NewState);

View File

@ -74,23 +74,23 @@ void LCD_Init(LCDDutyTypeDef duty, LCDBiasTypeDef bias);
// 输入值参考 LCDBiasTypeDef
#define LCD_BiasCfg( d ) (R32_LCD_CMD = (R32_LCD_CMD & ~RB_LCD_BIAS) | (d<<2)) /* 配置LCD的 bias选择 */
#define LCD_WriteData0( d ) (R32_LCD_RAM0 = (R32_LCD_RAM0 & 0xffffff00) | ((UINT32)d)) /* 填充LCD0驱动数值 */
#define LCD_WriteData1( d ) (R32_LCD_RAM0 = (R32_LCD_RAM0 & 0xffff00ff) | ((UINT32)d<<8)) /* 填充LCD1驱动数值 */
#define LCD_WriteData2( d ) (R32_LCD_RAM0 = (R32_LCD_RAM0 & 0xff00ffff) | ((UINT32)d<<16)) /* 填充LCD2驱动数值 */
#define LCD_WriteData3( d ) (R32_LCD_RAM0 = (R32_LCD_RAM0 & 0x00ffffff) | ((UINT32)d<<24)) /* 填充LCD3驱动数值 */
#define LCD_WriteData0( d ) (R32_LCD_RAM0 = (R32_LCD_RAM0 & 0xffffff00) | ((uint32_t)d)) /* 填充LCD0驱动数值 */
#define LCD_WriteData1( d ) (R32_LCD_RAM0 = (R32_LCD_RAM0 & 0xffff00ff) | ((uint32_t)d<<8)) /* 填充LCD1驱动数值 */
#define LCD_WriteData2( d ) (R32_LCD_RAM0 = (R32_LCD_RAM0 & 0xff00ffff) | ((uint32_t)d<<16)) /* 填充LCD2驱动数值 */
#define LCD_WriteData3( d ) (R32_LCD_RAM0 = (R32_LCD_RAM0 & 0x00ffffff) | ((uint32_t)d<<24)) /* 填充LCD3驱动数值 */
#define LCD_WriteData4( d ) (R32_LCD_RAM1 = (R32_LCD_RAM1 & 0xffffff00) | ((UINT32)d)) /* 填充LCD4驱动数值 */
#define LCD_WriteData5( d ) (R32_LCD_RAM1 = (R32_LCD_RAM1 & 0xffff00ff) | ((UINT32)d<<8)) /* 填充LCD5驱动数值 */
#define LCD_WriteData6( d ) (R32_LCD_RAM1 = (R32_LCD_RAM1 & 0xff00ffff) | ((UINT32)d<<16)) /* 填充LCD6驱动数值 */
#define LCD_WriteData7( d ) (R32_LCD_RAM1 = (R32_LCD_RAM1 & 0x00ffffff) | ((UINT32)d<<24)) /* 填充LCD7驱动数值 */
#define LCD_WriteData4( d ) (R32_LCD_RAM1 = (R32_LCD_RAM1 & 0xffffff00) | ((uint32_t)d)) /* 填充LCD4驱动数值 */
#define LCD_WriteData5( d ) (R32_LCD_RAM1 = (R32_LCD_RAM1 & 0xffff00ff) | ((uint32_t)d<<8)) /* 填充LCD5驱动数值 */
#define LCD_WriteData6( d ) (R32_LCD_RAM1 = (R32_LCD_RAM1 & 0xff00ffff) | ((uint32_t)d<<16)) /* 填充LCD6驱动数值 */
#define LCD_WriteData7( d ) (R32_LCD_RAM1 = (R32_LCD_RAM1 & 0x00ffffff) | ((uint32_t)d<<24)) /* 填充LCD7驱动数值 */
#define LCD_WriteData8( d ) (R32_LCD_RAM2 = (R32_LCD_RAM2 & 0xffffff00) | ((UINT32)d)) /* 填充LCD8驱动数值 */
#define LCD_WriteData9( d ) (R32_LCD_RAM2 = (R32_LCD_RAM2 & 0xffff00ff) | ((UINT32)d<<8)) /* 填充LCD9驱动数值 */
#define LCD_WriteData10( d ) (R32_LCD_RAM2 = (R32_LCD_RAM2 & 0xff00ffff) | ((UINT32)d<<16)) /* 填充LCD10驱动数值 */
#define LCD_WriteData11( d ) (R32_LCD_RAM2 = (R32_LCD_RAM2 & 0x00ffffff) | ((UINT32)d<<24)) /* 填充LCD11驱动数值 */
#define LCD_WriteData8( d ) (R32_LCD_RAM2 = (R32_LCD_RAM2 & 0xffffff00) | ((uint32_t)d)) /* 填充LCD8驱动数值 */
#define LCD_WriteData9( d ) (R32_LCD_RAM2 = (R32_LCD_RAM2 & 0xffff00ff) | ((uint32_t)d<<8)) /* 填充LCD9驱动数值 */
#define LCD_WriteData10( d ) (R32_LCD_RAM2 = (R32_LCD_RAM2 & 0xff00ffff) | ((uint32_t)d<<16)) /* 填充LCD10驱动数值 */
#define LCD_WriteData11( d ) (R32_LCD_RAM2 = (R32_LCD_RAM2 & 0x00ffffff) | ((uint32_t)d<<24)) /* 填充LCD11驱动数值 */
#define LCD_WriteData12( d ) (R32_LCD_RAM3 = (R32_LCD_RAM3 & 0xffffff00) | ((UINT32)d)) /* 填充LCD12驱动数值 */
#define LCD_WriteData13( d ) (R32_LCD_RAM3 = (R32_LCD_RAM3 & 0xffff00ff) | ((UINT32)d<<8)) /* 填充LCD13驱动数值 */
#define LCD_WriteData12( d ) (R32_LCD_RAM3 = (R32_LCD_RAM3 & 0xffffff00) | ((uint32_t)d)) /* 填充LCD12驱动数值 */
#define LCD_WriteData13( d ) (R32_LCD_RAM3 = (R32_LCD_RAM3 & 0xffff00ff) | ((uint32_t)d<<8)) /* 填充LCD13驱动数值 */

View File

@ -122,7 +122,7 @@ void SPI1_MasterDefInit(void);
*
* @param c -
*/
void SPI1_CLKCfg(UINT8 c);
void SPI1_CLKCfg(uint8_t c);
/**
* @brief
@ -136,14 +136,14 @@ void SPI1_DataMode(ModeBitOrderTypeDef m);
*
* @param d -
*/
void SPI1_MasterSendByte(UINT8 d);
void SPI1_MasterSendByte(uint8_t d);
/**
* @brief (buffer)
*
* @param none
*/
UINT8 SPI1_MasterRecvByte(void);
uint8_t SPI1_MasterRecvByte(void);
/**
* @brief 使FIFO连续发送多字节
@ -151,7 +151,7 @@ UINT8 SPI1_MasterRecvByte(void);
* @param pbuf -
* @param len - 4095
*/
void SPI1_MasterTrans(UINT8 *pbuf, UINT16 len);
void SPI1_MasterTrans(uint8_t *pbuf, uint16_t len);
/**
* @brief 使FIFO连续接收多字节
@ -159,7 +159,7 @@ void SPI1_MasterTrans(UINT8 *pbuf, UINT16 len);
* @param pbuf -
* @param len - 4095
*/
void SPI1_MasterRecv(UINT8 *pbuf, UINT16 len);
void SPI1_MasterRecv(uint8_t *pbuf, uint16_t len);
/**
* @brief MISO的GPIO对应为输入模式

View File

@ -70,13 +70,13 @@ typedef struct
typedef struct
{
UINT8 DeviceStatus; // 设备状态,0-无设备,1-有设备但尚未初始化,2-有设备但初始化枚举失败,3-有设备且初始化枚举成功
UINT8 DeviceAddress; // 设备被分配的USB地址
UINT8 DeviceSpeed; // 0为低速,非0为全速
UINT8 DeviceType; // 设备类型
UINT16 DeviceVID;
UINT16 DevicePID;
UINT8 GpVar[4]; // 通用变量
uint8_t DeviceStatus; // 设备状态,0-无设备,1-有设备但尚未初始化,2-有设备但初始化枚举失败,3-有设备且初始化枚举成功
uint8_t DeviceAddress; // 设备被分配的USB地址
uint8_t DeviceSpeed; // 0为低速,非0为全速
uint8_t DeviceType; // 设备类型
uint16_t DeviceVID;
uint16_t DevicePID;
uint8_t GpVar[4]; // 通用变量
} _DevOnHubPort; // 假定:不超过1个外部HUB,每个外部HUB不超过HUB_MAX_PORTS个端口(多了不管)
extern _RootHubDev ThisUsbDev;