reconfig src, new ver. rdwr_phy62x2.py, update LICENSE

This commit is contained in:
pvvx 2024-01-09 15:21:13 +03:00
parent a48f01f1ce
commit 67d10f06db
234 changed files with 1372 additions and 2309 deletions

33
LICENSE
View file

@ -1,3 +1,5 @@
SOURCE LICENSE:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation the
@ -10,3 +12,34 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
SDK LICENSE:
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.

View file

@ -22,7 +22,7 @@ Custom firmware for Tuya [THB2](https://pvvx.github.io/THB2).
1. Соединить GND, TX, RX, RTSRESET, VCC (+3.3B).
2. Запустить:
```
python3 rdwr_phy6222.py -p COM11 -r wh TestTHB2.hex
python3 rdwr_phy62x2.py -p COM11 -r wh TestTHB2.hex
```
3. Прошивка зашита. Устройство работает.
@ -37,7 +37,7 @@ python3 rdwr_phy6222.py -p COM11 -r wh TestTHB2.hex
1. Соединить GND, TX, RX, RTSRESET, VCC (+3.3B).
2. Запустить:
```
python3 rdwr_phy6222.py -p COM11 -r rc 0x11000000 0x80000 ff_thb2.bin
python3 rdwr_phy62x2.py -p COM11 -r rc 0x11000000 0x80000 ff_thb2.bin
```
3. Полученный файл ff_thb2.bin сохранить.
@ -47,7 +47,7 @@ python3 rdwr_phy6222.py -p COM11 -r rc 0x11000000 0x80000 ff_thb2.bin
2. Соединить GND, TX, RX, RTSRESET, VCC (+3.3B).
3. Запустить:
```
python3 rdwr_phy6222.py -p COM11 -b 1000000 -r we 0 ff_thb2.bin
python3 rdwr_phy62x2.py -p COM11 -b 1000000 -r we 0 ff_thb2.bin
```
Не все адаптеры USB-COM поддерживают 1Mbit. Тогда удалите опцию `-b 1000000` или выберите другой Baud rate.

View file

@ -208,7 +208,7 @@ DEFINES += -DPHY_MCU_TYPE=MCU_BUMBEE_M0
DEFINES += -DDEF_GAPBOND_MGR_ENABLE=0
DEFINES += -DUSE_FS=0
DEFINES += -DMAX_NUM_LL_CONN=1
DEFINES += -DXFLASH_HIGH_SPEED=1
#DEFINES += -DXFLASH_HIGH_SPEED=1
CFLAGS += $(DEFINES) $(INCLUDES)

1
bthome_phy6222/SDK/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
example

View file

@ -0,0 +1,28 @@
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.

View file

@ -1,8 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
Filename: ll.h
Revised:
@ -16,6 +11,7 @@
This API is based on the Bluetooth Core Specification,
V4.0.0, Vol. 6.
SDK_LICENSE
*******************************************************************************/

View file

@ -1,7 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*************
ll_buf.h
SDK_LICENSE
***************/
#ifndef _LL_BUF_H_
#define _LL_BUF_H_

View file

@ -1,7 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*************
ll_common.h
SDK_LICENSE
***************/
#ifndef _LL_H_
#define _LL_H_

View file

@ -1,8 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**
****************************************************************************************
*
@ -13,6 +8,8 @@
*
* $Rev: $
*
* SDK_LICENSE
*
****************************************************************************************
*/

View file

@ -1,7 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*************
ll_def.h
SDK_LICENSE
***************/
#ifndef LL_DEF_H_
#define LL_DEF_H_

View file

@ -1,8 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
Filename: ll_enc.h
Revised:
@ -14,6 +9,7 @@
This API is based on ULP BT LE D09R23.
SDK_LICENSE
*******************************************************************************/

View file

@ -1,7 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*************
ll_hw_drv.h
SDK_LICENSE
***************/
#ifndef _LL_HW_DRV_H_
#define _LL_HW_DRV_H_

View file

@ -1,7 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*************
ll_sleep.h
SDK_LICENSE
***************/
#ifndef LL_SLEEP__H_
#define LL_SLEEP__H_

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file rf_phy_driver.h
@brief
@ -9,15 +5,12 @@
@date 24. Aug. 2017
@author Zhongqi Yang
SDK_LICENSE
*******************************************************************************/
#ifndef __RF_PHY_DRIVER_H_
#define __RF_PHY_DRIVER_H_
/*******************************************************************************
INCLUDES
*/
@ -46,8 +39,6 @@ typedef enum _RX_ADC_CLK_SEL
} rxadc_clk_t;
/*******************************************************************************
Global Var
*/
@ -60,7 +51,7 @@ extern volatile uint8_t g_rfPhyPktFmt; //** rf_phy pkt format config
extern volatile uint32 g_rfPhyRxDcIQ; //** rx dc offset cal result **//
extern volatile int8_t g_rfPhyFreqOffSet;
extern volatile sysclk_t g_system_clk;
//extern volatile sysclk_t g_system_clk;
extern volatile rfphy_clk_t g_rfPhyClkSel;
extern volatile rxadc_clk_t g_rxAdcClkSel;

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
Filename: hci_c_data.h
Revised: $Date: 2011-08-22 08:41:40 -0700 (Mon, 22 Aug 2011) $
@ -9,7 +5,7 @@
Description: This file handles HCI data for the BLE Controller.
SDK_LICENSE
*******************************************************************************/
#ifndef HCI_C_DATA_H

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
Filename: hci_c_event.h
Revised: $Date: 2012-05-01 12:13:50 -0700 (Tue, 01 May 2012) $
@ -10,7 +6,7 @@
Description: This file contains the HCI Event types, contants,
external functions etc. for the BLE Controller.
SDK_LICENSE
*******************************************************************************/
#ifndef HCI_C_EVENT_H

View file

@ -1,10 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*************************************************************************************************
**************************************************************************************************/
/*************
hci_host.h
SDK_LICENSE
***************/
#ifndef HCI_HOST_H
#define HCI_HOST_H

View file

@ -1,9 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*************************************************************************************************
**************************************************************************************************/
/*************
hci_task.h
SDK_LICENSE
***************/
#ifndef HCI_TASK_H
#define HCI_TASK_H

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
Filename: hci_tl.h
Revised: $Date: 2012-04-20 15:24:45 -0700 (Fri, 20 Apr 2012) $
@ -10,6 +6,7 @@
Description: This file contains the types, contants, external functions
etc. for the BLE HCI Transport Layer.
SDK_LICENSE
*******************************************************************************/
#ifndef HCI_TL_H

View file

@ -1,11 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**************************************************************************************************
**************************************************************************************************/
/*************
att_internal.h
SDK_LICENSE
***************/
#ifndef ATT_INTERNAL_H
#define ATT_INTERNAL_H

View file

@ -1,10 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**************************************************************************************************
**************************************************************************************************/
/*************
gap_internal.h
SDK_LICENSE
***************/
#ifndef GAP_INTERNAL_H
#define GAP_INTERNAL_H

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**************************************************************************************************
Filename: gapgattserver.h
Revised:
@ -10,8 +6,7 @@
Description: This file contains GAP GATT attribute definitions
and prototypes.
SDK_LICENSE
**************************************************************************************************/
#ifndef GAPGATTSERVER_H

View file

@ -1,9 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**************************************************************************************************
**************************************************************************************************/
/*************
gatt_internal.h
SDK_LICENSE
***************/
#ifndef GATT_INTERNAL_H
#define GATT_INTERNAL_H

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**************************************************************************************************
Filename: gatt_profile_uuid.h
Revised:
@ -9,7 +5,7 @@
Description: This file contains GATT Profile UUID types.
SDK_LICENSE
**************************************************************************************************/

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**
@headerfile: gattservapp.h
@ -13,6 +9,7 @@
Description: This file contains the GATT Server Application (GATTServApp)
definitions and prototypes.<BR><BR>
SDK_LICENSE
**************************************************************************************************/

View file

@ -1,9 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**************************************************************************************************
**************************************************************************************************/
/*************
gatttest.h
SDK_LICENSE
***************/
#ifndef GATTTEST_H
#define GATTTEST_H

View file

@ -1,9 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**************************************************************************************************
**************************************************************************************************/
/*************
l2cap_internal.h
SDK_LICENSE
***************/
#ifndef L2CAP_INTERNAL_H
#define L2CAP_INTERNAL_H

View file

@ -1,8 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**************************************************************************************************
Filename: linkdb.h
Revised:
@ -10,7 +5,7 @@
Description: This file contains the linkDB interface.
SDK_LICENSE
**************************************************************************************************/
#ifndef LINKDB_H

View file

@ -1,10 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**************************************************************************************************
**************************************************************************************************/
/*************
sm_internal.h
SDK_LICENSE
***************/
#ifndef SM_INTERNAL_H
#define SM_INTERNAL_H

View file

@ -1,9 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**************************************************************************************************
**************************************************************************************************/
/*************
smp.h
SDK_LICENSE
***************/
#ifndef SMP_H
#define SMP_H

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**
@headerfile: att.h
@ -12,9 +8,10 @@
Description: This file contains Attribute Protocol (ATT) definitions
and prototypes.
-->
SDK_LICENSE
**************************************************************************************************/
#ifndef ATT_H

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**
@headerfile: bcomdef.h
@ -13,6 +9,7 @@
-->
SDK_LICENSE
**************************************************************************************************/
#ifndef BCOMDEF_H

View file

@ -1,12 +1,9 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**
@headerfile: gap.h
$Date:
$Revision:
SDK_LICENSE
*/

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**
@headerfile: gatt.h
$Date:
@ -12,6 +8,7 @@
Description: This file contains Generic Attribute Profile (GATT)
definitions and prototypes.<BR><BR>
SDK_LICENSE
*/
@ -80,7 +77,9 @@ extern "C"
/** @} End GATT_MAX_ATTR_SIZE_DEFINES */
// GATT Maximum number of connections (including loopback)
#ifndef GATT_MAX_NUM_CONN
#define GATT_MAX_NUM_CONN ( MAX_NUM_LL_CONN + 1 )
#endif
// GATT Base Method
#define GATT_BASE_METHOD 0x40

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**************************************************************************************************
Filename: gatt_uuid.h
Revised:
@ -10,6 +6,7 @@
Description: This file contains Generic Attribute Profile (GATT)
UUID types.
SDK_LICENSE
**************************************************************************************************/

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
Filename: hci.h
Revised:
@ -14,6 +10,7 @@
All Bluetooth and BLE commands are based on:
Bluetooth Core Specification, V4.0.0, Vol. 2, Part E.
SDK_LICENSE
*******************************************************************************/

View file

@ -1,8 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**************************************************************************************************
Filename: l2cap.h
Revised:
@ -10,6 +5,7 @@
Description: This file contains the L2CAP definitions.
SDK_LICENSE
**************************************************************************************************/

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**
@headerfile: sm.h
$Date:
@ -11,7 +7,7 @@
This file contains the interface to the SM.
SDK_LICENSE
*/

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file adc.c
@brief Contains all functions support for adc driver
@ -9,7 +5,7 @@
@date 18. Oct. 2017
@author qing.han
SDK_LICENSE
*******************************************************************************/
#include <string.h>

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file adc.h
@brief Contains all functions support for adc driver
@ -9,7 +5,7 @@
@date 18. Oct. 2017
@author qing.han
SDK_LICENSE
*******************************************************************************/
#ifndef __ADC__H__

View file

@ -1,17 +0,0 @@
调用hal_adc_start的同时启动一个oals_timer.
example:
//triggle function
hal_adc_start();
osal_start_timerEx(adcDemo_TaskID, adcProctect_EVT,50);
...............
...............
//osal task event process
if(event&adcProctect_EVT)
{
hal_adc_stop();
hal_clk_reset(MOD_ADCC);
return (event^adcProctect_EVT)
}

View file

@ -1,3 +1,8 @@
/*************
bsp_button.c
SDK_LICENSE
***************/
#include "error.h"
#include "bsp_button.h"
#include "log.h"

View file

@ -1,3 +1,8 @@
/*************
bsp_button.h
SDK_LICENSE
***************/
#ifndef __BSP_BUTTON_H__
#define __BSP_BUTTON_H__

View file

@ -1,11 +1,8 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**************************************************************************************************
Filename: bsp_button_task.c
Revised: $Date $
Revision: $Revision $
SDK_LICENSE
**************************************************************************************************/
/*********************************************************************

View file

@ -1,12 +1,9 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**************************************************************************************************
Filename: bsp_button_task.h
Revised: $Date $
Revision: $Revision $
SDK_LICENSE
**************************************************************************************************/
#ifndef __BSP_BUTTON_TASK_H__

View file

@ -1,16 +1,13 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**************************************************************
Module Name: bsp_gpio
File name: bsp_gpio.c
Brief description:
key driver module
Data: 2020-06-30
Revision:V0.01
SDK_LICENSE
****************************************************************/
#include "bsp_gpio.h"

View file

@ -1,15 +1,13 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**************************************************************
Module Name: bsp_gpio
File name: bsp_gpio.h
Brief description:
key driver module
Data: 2020-06-30
Revision:V0.01
SDK_LICENSE
****************************************************************/
#ifndef __KEY_H__

View file

@ -1,6 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*************
clock.c
SDK_LICENSE
***************/
#include "clock.h"
#include "gpio.h"
#include "global_config.h"

View file

@ -1,6 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*************
clock.h
SDK_LICENSE
***************/
#ifndef _HAL_CLOCK_H
#define _HAL_CLOCK_H
@ -41,6 +42,12 @@ typedef enum _SYSCLK_SEL
SYS_CLK_NUM = 8,
} sysclk_t;
#ifdef USE_ROMSYM_ALIAS
extern sysclk_t _symrom_g_system_clk;
#else
extern sysclk_t g_system_clk;
#endif
typedef enum
{
HCLK_CHANGE = 0,

View file

@ -1,7 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*************
dma.c
SDK_LICENSE
***************/
#include <string.h>

View file

@ -1,7 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*************
dma.h
SDK_LICENSE
***************/
/* Peripheral group ----------------------------------------------------------- */
/** @defgroup GPDMA GPDMA (General Purpose Direct Memory Access)

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file flash.c
@brief Contains all functions support for flash driver
@ -9,7 +5,7 @@
@date 27. Nov. 2017
@author qing.han
SDK_LICENSE
*******************************************************************************/
#include "rom_sym_def.h"

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file flash.h
@brief Contains all functions support for flash driver
@ -9,7 +5,7 @@
@date 27. Nov. 2017
@author qing.han
SDK_LICENSE
*******************************************************************************/
#ifndef _FLASH_H_

View file

@ -1,35 +1,3 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/*******************************************************************************
@file gpio.c
@brief Contains all functions support for gpio and iomux driver
@ -37,7 +5,7 @@
@date 19. Oct. 2017
@author qing.han
SDK_LICENSE
*******************************************************************************/
#include "types.h"

View file

@ -1,35 +1,3 @@
/**************************************************************************************************
Phyplus Microelectronics Limited confidential and proprietary.
All rights reserved.
IMPORTANT: All rights of this software belong to Phyplus Microelectronics
Limited ("Phyplus"). Your use of this Software is limited to those
specific rights granted under the terms of the business contract, the
confidential agreement, the non-disclosure agreement and any other forms
of agreements as a customer or a partner of Phyplus. You may not use this
Software unless you agree to abide by the terms of these agreements.
You acknowledge that the Software may not be modified, copied,
distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
(BLE) integrated circuit, either as a product or is integrated into your
products. Other than for the aforementioned purposes, you may not use,
reproduce, copy, prepare derivative works of, modify, distribute, perform,
display or sell this Software and/or its documentation for any purposes.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
**************************************************************************************************/
/*******************************************************************************
@file gpio.h
@brief Contains all functions support for gpio and iomux driver
@ -37,7 +5,7 @@
@date 19. Oct. 2017
@author qing.han
SDK_LICENSE
*******************************************************************************/
#ifndef __GPIO_H__

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file i2c.c
@brief Contains all functions support for i2c driver
@ -9,7 +5,7 @@
@date 25. Oct. 2017
@author qing.han
SDK_LICENSE
*******************************************************************************/

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file i2c.h
@brief Contains all functions support for i2c driver
@ -9,7 +5,7 @@
@date 25. Oct. 2017
@author qing.han
SDK_LICENSE
*******************************************************************************/
#ifndef __I2C__H__

View file

@ -1,12 +1,9 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file i2c_comman.c
@brief i2c general Function
@version 1.0
SDK_LICENSE
*******************************************************************************/

View file

@ -1,12 +1,10 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file i2c_comman.h
@brief i2c General Configuration
@version 1.0
SDK_LICENSE
*******************************************************************************/
#ifndef __I2C_COMMON_H__

View file

@ -1,3 +1,8 @@
/*************
i2c_io.c
SDK_LICENSE
***************/
//#include "iic.h"
#include "bus_dev.h"
#include "gpio.h"

View file

@ -1,3 +1,8 @@
/*************
i2c_io.h
SDK_LICENSE
***************/
#ifndef __IIC_H
#define __IIC_H

View file

@ -1,7 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*************
i2c_s.c
SDK_LICENSE
***************/
#include "bus_dev.h"
#include "gpio.h"

View file

@ -1,7 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*************
i2c_s.h
SDK_LICENSE
***************/
#ifndef _IIC_SLAVE_H
#define _IIC_SLAVE_H

View file

@ -1,12 +1,10 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file i2c_slave.c
@brief i2c slave function
@version 1.0
SDK_LICENSE
*******************************************************************************/
/*******************************************************************************

View file

@ -1,12 +1,10 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file i2c_slave.h
@brief i2c slave Configuration,API...
@version 1.0
SDK_LICENSE
*******************************************************************************/
#ifndef __I2C_SLAVE_H__

View file

@ -1,16 +1,13 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**************************************************************
Module Name: key
File name: key.c
Brief description:
key driver module
Data: 2020-06-30
Revision:V0.01
SDK_LICENSE
****************************************************************/
#include "rom_sym_def.h"
#include "key.h"
@ -21,7 +18,7 @@
key_contex_t key_state;
extern uint32 getMcuPrecisionCount(void);
//extern uint32 getMcuPrecisionCount(void);
static int key_timer_start(uint32 intval_ms)
{

View file

@ -1,15 +1,13 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**************************************************************
Module Name: key
File name: key.h
Brief description:
key driver module
Data: 2020-06-30
Revision:V0.01
SDK_LICENSE
****************************************************************/
#ifndef __KEY_H__

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file kscan.c
@brief Contains all functions support for key scan driver
@ -9,7 +5,7 @@
@date 13. Nov. 2017
@author Ding
SDK_LICENSE
*******************************************************************************/
#include "rom_sym_def.h"

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file kscan.h
@brief Contains all functions support for key scan driver
@ -9,7 +5,7 @@
@date 13. Nov. 2017
@author Ding
SDK_LICENSE
*******************************************************************************/
#ifndef __KSCAN__H__

View file

@ -1,3 +1,7 @@
/*************
led_light.h
SDK_LICENSE
***************/
#include "led_light.h"
#include "pwm.h"

View file

@ -1,3 +1,7 @@
/*************
led_light.c
SDK_LICENSE
***************/
#ifndef _LED_LIGHT_H
#define _LED_LIGHT_H

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file log.h
@brief Contains all functions support for uart driver
@ -9,7 +5,7 @@
@date 31. Jan. 2018
@author eagle.han
SDK_LICENSE
*******************************************************************************/
#ifndef ENABLE_LOG_ROM

View file

@ -1,3 +1,7 @@
/*************
my_printf.c
SDK_LICENSE
***************/
#include "rom_sym_def.h"
#include "types.h"

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file pwm.c
@brief Contains all functions support for pwm driver
@ -9,7 +5,7 @@
@date 30. Oct. 2017
@author Ding
SDK_LICENSE
*******************************************************************************/
#include "rom_sym_def.h"

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file pwm.h
@brief Contains all functions support for pwm driver
@ -9,7 +5,7 @@
@date 30. Oct. 2017
@author Ding
SDK_LICENSE
*******************************************************************************/
#ifndef __PWM__H__

View file

@ -1,8 +1,9 @@
/**************************************************************************************************
*******
**************************************************************************************************/
#include "rom_sym_def.h"
/************
pwrmgr.c
SDK_LICENSE
**************/
#include "types.h"
#include "rom_sym_def.h"
#include "ll_sleep.h"
#include "bus_dev.h"
#include "string.h"
@ -14,517 +15,593 @@
#include "clock.h"
#include "jump_function.h"
#include "flash.h"
#include "rf_phy_driver.h"
#if(CFG_SLEEP_MODE == PWR_MODE_NO_SLEEP)
static uint8_t mPwrMode = PWR_MODE_NO_SLEEP;
#elif(CFG_SLEEP_MODE == PWR_MODE_SLEEP)
static uint8_t mPwrMode = PWR_MODE_SLEEP;
#elif(CFG_SLEEP_MODE == PWR_MODE_PWROFF_NO_SLEEP)
static uint8_t mPwrMode = PWR_MODE_PWROFF_NO_SLEEP;
static uint8_t mPwrMode = PWR_MODE_NO_SLEEP;
#elif(CFG_SLEEP_MODE == PWR_MODE_SLEEP)
static uint8_t mPwrMode = PWR_MODE_SLEEP;
#elif(CFG_SLEEP_MODE == PWR_MODE_PWROFF_NO_SLEEP)
static uint8_t mPwrMode = PWR_MODE_PWROFF_NO_SLEEP;
#else
#error "CFG_SLEEP_MODE define incorrect"
#error "CFG_SLEEP_MODE define incorrect"
#endif
//#define CFG_FLASH_ENABLE_DEEP_SLEEP
#ifdef CFG_FLASH_ENABLE_DEEP_SLEEP
#warning "CONFIG FLASH ENABLE DEEP SLEEP !!!"
#warning "CONFIG FLASH ENABLE DEEP SLEEP !!!"
#endif
#define CFG_SRAM_RETENTION_LOW_CURRENT_LDO_ENABLE
#ifdef CFG_SRAM_RETENTION_LOW_CURRENT_LDO_ENABLE
// #warning "ENABLE LOW CURRENT LDO FOR SRAM RETENTION !!!"
// #warning "ENABLE LOW CURRENT LDO FOR SRAM RETENTION !!!"
#endif
//#define CFG_HCLK_DYNAMIC_CHANGE
#if(CFG_HCLK_DYNAMIC_CHANGE)
#warning "ENABLE CFG_HCLK_DYNAMIC_CHANGE !!!"
#endif
typedef struct _pwrmgr_Context_t
{
MODULE_e moudle_id;
bool lock;
pwrmgr_Hdl_t sleep_handler;
pwrmgr_Hdl_t wakeup_handler;
MODULE_e moudle_id;
bool lock;
pwrmgr_Hdl_t sleep_handler;
pwrmgr_Hdl_t wakeup_handler;
} pwrmgr_Ctx_t;
static pwrmgr_Ctx_t mCtx[HAL_PWRMGR_TASK_MAX_NUM];
static uint32_t sramRet_config;
static PWRMGR_CFG_BIT s_pwrmgr_cfg;
static uint32_t s_config_swClk0 = DEF_CLKG_CONFIG_0;
uint32_t s_config_swClk1 = DEF_CLKG_CONFIG_1;
uint32_t s_gpio_wakeup_src_group1, s_gpio_wakeup_src_group2;
/*
osal_idle_task will be call
*/
__ATTR_SECTION_SRAM__ void osal_idle_task (void)
{
AP_WDT_FEED;
osal_pwrmgr_powerconserve0();
}
#if(CFG_SLEEP_MODE == PWR_MODE_SLEEP)
uint32_t s_gpio_wakeup_src_group1,s_gpio_wakeup_src_group2;
#endif
// /*
// osal_idle_task will be call
// */
// extern void osal_pwrmgr_powerconserve1( void );
// __ATTR_SECTION_SRAM__ void osal_idle_task (void)
// {
// AP_WDT_FEED;
// osal_pwrmgr_powerconserve1();
// }
int hal_pwrmgr_init(void)
{
memset(&mCtx, 0, sizeof(mCtx));
memset(&mCtx, 0, sizeof(mCtx));
switch(mPwrMode)
{
case PWR_MODE_NO_SLEEP:
case PWR_MODE_PWROFF_NO_SLEEP:
disableSleep();
break;
switch(mPwrMode)
{
case PWR_MODE_NO_SLEEP:
case PWR_MODE_PWROFF_NO_SLEEP:
disableSleep();
break;
case PWR_MODE_SLEEP:
enableSleep();
break;
}
case PWR_MODE_SLEEP:
enableSleep();
break;
}
/*
if wdt enable, set osal idle task to feed wdt before powerconserve
*/
if(AP_WDT_ENABLE_STATE)
JUMP_FUNCTION(OSAL_POWER_CONSERVE)=(uint32_t)&osal_idle_task;
return PPlus_SUCCESS;
// /*
// if wdt enable, set osal idle task to feed wdt before powerconserve
// */
// if(AP_WDT_ENABLE_STATE)
// JUMP_FUNCTION(OSAL_POWER_CONSERVE)=(uint32_t)&osal_idle_task;
return PPlus_SUCCESS;
}
int hal_pwrmgr_clk_gate_config(MODULE_e module)
{
if (module < MOD_CP_CPU)
{
s_config_swClk0 |= BIT(module);
}
else if (module < MOD_PCLK_CACHE)
{
s_config_swClk1 |= BIT(module - MOD_CP_CPU);
}
if (module < MOD_CP_CPU)
{
s_config_swClk0 |= BIT(module);
}
else if (module < MOD_PCLK_CACHE)
{
s_config_swClk1 |= BIT(module - MOD_CP_CPU);
}
return PPlus_SUCCESS;
return PPlus_SUCCESS;
}
bool hal_pwrmgr_is_lock(MODULE_e mod)
{
int i;
int ret = FALSE;
int i;
int ret = FALSE;
if(mPwrMode == PWR_MODE_NO_SLEEP || mPwrMode == PWR_MODE_PWROFF_NO_SLEEP )
{
return TRUE;
}
if(mPwrMode == PWR_MODE_NO_SLEEP || mPwrMode == PWR_MODE_PWROFF_NO_SLEEP )
{
return TRUE;
}
HAL_ENTER_CRITICAL_SECTION();
HAL_ENTER_CRITICAL_SECTION();
for(i = 0; i< HAL_PWRMGR_TASK_MAX_NUM; i++)
{
if(mCtx[i].moudle_id == MOD_NONE)
break;
for(i = 0; i< HAL_PWRMGR_TASK_MAX_NUM; i++)
{
if(mCtx[i].moudle_id == MOD_NONE)
break;
if(mCtx[i].moudle_id == mod)
{
if(mCtx[i].lock == TRUE)
ret = TRUE;
if(mCtx[i].moudle_id == mod)
{
if(mCtx[i].lock == TRUE)
ret = TRUE;
break;
}
}
break;
}
}
HAL_EXIT_CRITICAL_SECTION();
return ret;
HAL_EXIT_CRITICAL_SECTION();
return ret;
}
int hal_pwrmgr_lock(MODULE_e mod)
{
int i;
int ret = PPlus_ERR_NOT_REGISTED;
int i;
int ret = PPlus_ERR_NOT_REGISTED;
if(mPwrMode == PWR_MODE_NO_SLEEP || mPwrMode == PWR_MODE_PWROFF_NO_SLEEP )
{
disableSleep();
return PPlus_SUCCESS;
}
if(mPwrMode == PWR_MODE_NO_SLEEP || mPwrMode == PWR_MODE_PWROFF_NO_SLEEP )
{
disableSleep();
return PPlus_SUCCESS;
}
HAL_ENTER_CRITICAL_SECTION();
HAL_ENTER_CRITICAL_SECTION();
for(i = 0; i< HAL_PWRMGR_TASK_MAX_NUM; i++)
{
if(mCtx[i].moudle_id == MOD_NONE)
break;
for(i = 0; i< HAL_PWRMGR_TASK_MAX_NUM; i++)
{
if(mCtx[i].moudle_id == MOD_NONE)
break;
if(mCtx[i].moudle_id == mod)
{
mCtx[i].lock = TRUE;
disableSleep();
//LOG("LOCK\n");
ret = PPlus_SUCCESS;
break;
}
}
if(mCtx[i].moudle_id == mod)
{
mCtx[i].lock = TRUE;
disableSleep();
//LOG("LOCK\n");
ret = PPlus_SUCCESS;
break;
}
}
HAL_EXIT_CRITICAL_SECTION();
return ret;
HAL_EXIT_CRITICAL_SECTION();
return ret;
}
int hal_pwrmgr_unlock(MODULE_e mod)
{
int i, cnt = 0;
int i, cnt = 0;
if(mPwrMode == PWR_MODE_NO_SLEEP || mPwrMode == PWR_MODE_PWROFF_NO_SLEEP )
{
disableSleep();
return PPlus_SUCCESS;
}
if(mPwrMode == PWR_MODE_NO_SLEEP || mPwrMode == PWR_MODE_PWROFF_NO_SLEEP )
{
disableSleep();
return PPlus_SUCCESS;
}
HAL_ENTER_CRITICAL_SECTION();
HAL_ENTER_CRITICAL_SECTION();
for(i = 0; i< HAL_PWRMGR_TASK_MAX_NUM; i++)
{
if(mCtx[i].moudle_id == MOD_NONE)
break;
for(i = 0; i< HAL_PWRMGR_TASK_MAX_NUM; i++)
{
if(mCtx[i].moudle_id == MOD_NONE)
break;
if(mCtx[i].moudle_id == mod)
{
mCtx[i].lock = FALSE;
}
if(mCtx[i].moudle_id == mod)
{
mCtx[i].lock = FALSE;
}
if(mCtx[i].lock)
cnt ++;
}
if(mCtx[i].lock)
cnt ++;
}
if(cnt == 0)
enableSleep();
else
disableSleep();
if(cnt == 0)
enableSleep();
else
disableSleep();
HAL_EXIT_CRITICAL_SECTION();
//LOG("sleep mode:%d\n", isSleepAllow());
return PPlus_SUCCESS;
HAL_EXIT_CRITICAL_SECTION();
//LOG("sleep mode:%d\n", isSleepAllow());
return PPlus_SUCCESS;
}
int hal_pwrmgr_register(MODULE_e mod, pwrmgr_Hdl_t sleepHandle, pwrmgr_Hdl_t wakeupHandle)
{
int i;
pwrmgr_Ctx_t* pctx = NULL;
int i;
pwrmgr_Ctx_t* pctx = NULL;
for(i = 0; i< HAL_PWRMGR_TASK_MAX_NUM; i++)
{
if(mCtx[i].moudle_id == mod)
return PPlus_ERR_INVALID_STATE;
for(i = 0; i< HAL_PWRMGR_TASK_MAX_NUM; i++)
{
if(mCtx[i].moudle_id == mod)
return PPlus_ERR_INVALID_STATE;
if(mCtx[i].moudle_id == MOD_NONE)
{
pctx = &mCtx[i];
break;
}
}
if(mCtx[i].moudle_id == MOD_NONE)
{
pctx = &mCtx[i];
s_pwrmgr_cfg.moudle_num++;
break;
}
}
if(pctx == NULL)
return PPlus_ERR_NO_MEM;
if(pctx == NULL)
return PPlus_ERR_NO_MEM;
pctx->lock = FALSE;
pctx->moudle_id = mod;
pctx->sleep_handler = sleepHandle;
pctx->wakeup_handler = wakeupHandle;
return PPlus_SUCCESS;
pctx->lock = FALSE;
pctx->moudle_id = mod;
pctx->sleep_handler = sleepHandle;
pctx->wakeup_handler = wakeupHandle;
return PPlus_SUCCESS;
}
int hal_pwrmgr_unregister(MODULE_e mod)
{
int i;
pwrmgr_Ctx_t* pctx = NULL;
int i;
pwrmgr_Ctx_t* pctx = NULL;
for(i = 0; i< HAL_PWRMGR_TASK_MAX_NUM; i++)
{
if(mCtx[i].moudle_id == mod)
{
pctx = &mCtx[i];
break;
}
for(i = 0; i< HAL_PWRMGR_TASK_MAX_NUM; i++)
{
if(mCtx[i].moudle_id == mod)
{
s_pwrmgr_cfg.moudle_num--;
pctx = &mCtx[i];
break;
}
if(mCtx[i].moudle_id == MOD_NONE)
{
return PPlus_ERR_NOT_REGISTED;
}
}
if(mCtx[i].moudle_id == MOD_NONE)
{
return PPlus_ERR_NOT_REGISTED;
}
}
if(pctx == NULL)
return PPlus_ERR_NOT_REGISTED;
if(pctx == NULL)
return PPlus_ERR_NOT_REGISTED;
HAL_ENTER_CRITICAL_SECTION();
memcpy(pctx, pctx+1, sizeof(pwrmgr_Ctx_t)*(HAL_PWRMGR_TASK_MAX_NUM-i-1));
HAL_EXIT_CRITICAL_SECTION();
return PPlus_SUCCESS;
HAL_ENTER_CRITICAL_SECTION();
memcpy(pctx, pctx+1, sizeof(pwrmgr_Ctx_t)*(HAL_PWRMGR_TASK_MAX_NUM-i-1));
HAL_EXIT_CRITICAL_SECTION();
return PPlus_SUCCESS;
}
void clk_change_mod_restore(void)
{
int i;
for(i = 0; i< HAL_PWRMGR_TASK_MAX_NUM; i++)
{
if(mCtx[i].moudle_id == MOD_NONE)
{
return ;
}
if(mCtx[i].wakeup_handler)
mCtx[i].wakeup_handler();
}
return;
}
#if(CFG_SLEEP_MODE == PWR_MODE_SLEEP)
void peripheral_interrupt_restore_default(void)
{
NVIC_SetPriority((IRQn_Type)KSCAN_IRQn, IRQ_PRIO_HAL);
NVIC_SetPriority((IRQn_Type)WDT_IRQn, IRQ_PRIO_HAL);
NVIC_SetPriority((IRQn_Type)UART0_IRQn, IRQ_PRIO_HAL);
NVIC_SetPriority((IRQn_Type)UART1_IRQn, IRQ_PRIO_HAL);
NVIC_SetPriority((IRQn_Type)I2C0_IRQn, IRQ_PRIO_HAL);
NVIC_SetPriority((IRQn_Type)I2C1_IRQn, IRQ_PRIO_HAL);
NVIC_SetPriority((IRQn_Type)SPI0_IRQn, IRQ_PRIO_HAL);
NVIC_SetPriority((IRQn_Type)SPI1_IRQn, IRQ_PRIO_HAL);
NVIC_SetPriority((IRQn_Type)GPIO_IRQn, IRQ_PRIO_HAL);
NVIC_SetPriority((IRQn_Type)DMAC_IRQn, IRQ_PRIO_HAL);
NVIC_SetPriority((IRQn_Type)TIM5_IRQn, IRQ_PRIO_HAL);
NVIC_SetPriority((IRQn_Type)TIM6_IRQn, IRQ_PRIO_HAL);
NVIC_SetPriority((IRQn_Type)ADCC_IRQn, IRQ_PRIO_HAL);
}
int __attribute__((used)) hal_pwrmgr_wakeup_process(void)
{
int i;
#ifdef CFG_FLASH_ENABLE_DEEP_SLEEP
extern void spif_release_deep_sleep(void);
spif_release_deep_sleep();
WaitRTCCount(8); // 8*32us
#endif
AP_PCR->SW_CLK = s_config_swClk0;
AP_PCR->SW_CLK1 = s_config_swClk1 | 0x01; //force set M0 CPU
s_gpio_wakeup_src_group1 = AP_AON->GPIO_WAKEUP_SRC[0];
s_gpio_wakeup_src_group2 = AP_AON->GPIO_WAKEUP_SRC[1];
//restore BB TIMER IRQ_PRIO
NVIC_SetPriority((IRQn_Type)BB_IRQn, IRQ_PRIO_REALTIME);
NVIC_SetPriority((IRQn_Type)TIM1_IRQn, IRQ_PRIO_HIGH); //ll_EVT
NVIC_SetPriority((IRQn_Type)TIM2_IRQn, IRQ_PRIO_HIGH); //OSAL_TICK
NVIC_SetPriority((IRQn_Type)TIM4_IRQn, IRQ_PRIO_HIGH); //LL_EXA_ADV
int i;
#ifdef CFG_FLASH_ENABLE_DEEP_SLEEP
extern void spif_release_deep_sleep(void);
spif_release_deep_sleep();
WaitRTCCount(8);
#endif
AP_PCR->SW_CLK = s_config_swClk0;
AP_PCR->SW_CLK1 = s_config_swClk1|0x01;//force set M0 CPU
s_gpio_wakeup_src_group1 = AP_AON->GPIO_WAKEUP_SRC[0];
s_gpio_wakeup_src_group2 = AP_AON->GPIO_WAKEUP_SRC[1];
//restore BB TIMER IRQ_PRIO
NVIC_SetPriority((IRQn_Type)BB_IRQn, IRQ_PRIO_REALTIME);
NVIC_SetPriority((IRQn_Type)TIM1_IRQn, IRQ_PRIO_HIGH); //ll_EVT
NVIC_SetPriority((IRQn_Type)TIM2_IRQn, IRQ_PRIO_HIGH); //OSAL_TICK
NVIC_SetPriority((IRQn_Type)TIM4_IRQn, IRQ_PRIO_HIGH); //LL_EXA_ADV
//peripheral_interrupt_restore_default();
for(i = 0; i< HAL_PWRMGR_TASK_MAX_NUM; i++)
{
if(mCtx[i].moudle_id == MOD_NONE)
{
return PPlus_ERR_NOT_REGISTED;
}
for(i = 0; i< s_pwrmgr_cfg.moudle_num; i++)
{
if(mCtx[i].moudle_id == MOD_NONE)
{
return PPlus_ERR_NOT_REGISTED;
}
if(mCtx[i].wakeup_handler)
mCtx[i].wakeup_handler();
}
if(mCtx[i].wakeup_handler)
mCtx[i].wakeup_handler();
}
return PPlus_SUCCESS;
return PPlus_SUCCESS;
}
int __attribute__((used)) hal_pwrmgr_sleep_process(void)
{
int i;
//20181013 ZQ :
hal_pwrmgr_RAM_retention_set();
int i;
//20181013 ZQ :
hal_pwrmgr_RAM_retention_set();
//LOG("Sleep\n");
for(i = 0; i< HAL_PWRMGR_TASK_MAX_NUM; i++)
{
if(mCtx[i].moudle_id == MOD_NONE)
{
//return PPlus_ERR_NOT_REGISTED;
//found last module
break;
}
//LOG("Sleep\n");
for(i = s_pwrmgr_cfg.moudle_num-1; i >= 0; i--)
{
if(mCtx[i].moudle_id == MOD_NONE)
{
return PPlus_ERR_NOT_REGISTED;
}
if(mCtx[i].sleep_handler)
mCtx[i].sleep_handler();
}
if(mCtx[i].sleep_handler)
mCtx[i].sleep_handler();
}
#ifdef CFG_FLASH_ENABLE_DEEP_SLEEP
extern void spif_set_deep_sleep(void);
spif_set_deep_sleep();
#if(CFG_HCLK_DYNAMIC_CHANGE==1)
/*
hclk will change to SYS_CLK_XTAL_16M in next wakeup_process
*/
hal_system_clock_change_req(SYS_CLK_XTAL_16M);
#endif
return PPlus_SUCCESS;
#ifdef CFG_FLASH_ENABLE_DEEP_SLEEP
extern void spif_set_deep_sleep(void);
spif_set_deep_sleep();
#endif
return PPlus_SUCCESS;
}
#else
int __attribute__((used)) hal_pwrmgr_wakeup_process(void)
{
return PPlus_SUCCESS;
}
int __attribute__((used)) hal_pwrmgr_sleep_process(void)
{
return PPlus_SUCCESS;
}
#endif
/**************************************************************************************
@fn hal_pwrmgr_RAM_retention
@fn hal_pwrmgr_RAM_retention
@brief This function process for enable retention sram
@brief This function process for enable retention sram
input parameters
input parameters
@param uint32_t sram: sram bit map
@param uint32_t sram: sram bit map
output parameters
output parameters
@param None.
@param None.
@return refer error.h.
@return refer error.h.
**************************************************************************************/
int hal_pwrmgr_RAM_retention(uint32_t sram)
{
if(sram & 0xffffffe0)
{
sramRet_config = 0x00;
return PPlus_ERR_INVALID_PARAM;
}
if(sram & 0xffffffe0)
{
s_pwrmgr_cfg.sramRet_config = 0x00;
return PPlus_ERR_INVALID_PARAM;
}
sramRet_config = sram;
return PPlus_SUCCESS;
s_pwrmgr_cfg.sramRet_config = sram;
return PPlus_SUCCESS;
}
int hal_pwrmgr_RAM_retention_clr(void)
{
subWriteReg(0x4000f01c,21,17,0);
return PPlus_SUCCESS;
subWriteReg(0x4000f01c,21,17,0);
return PPlus_SUCCESS;
}
int hal_pwrmgr_RAM_retention_set(void)
{
subWriteReg(0x4000f01c,21,17,sramRet_config);
return PPlus_SUCCESS;
subWriteReg(0x4000f01c,21,17,s_pwrmgr_cfg.sramRet_config);
return PPlus_SUCCESS;
}
int hal_pwrmgr_LowCurrentLdo_enable(void)
{
#ifdef CFG_SRAM_RETENTION_LOW_CURRENT_LDO_ENABLE
uint32_t retention_flag;
hal_flash_read(0x1100181c,(uint8_t*)&retention_flag,4);
uint32_t retention_flag;
hal_flash_read(0x1100181c,(uint8_t*)&retention_flag,4);
if(retention_flag == 0xffffffff)
{
subWriteReg(0x4000f014,26,26, 1);
}
if(retention_flag == 0xffffffff)
{
subWriteReg(0x4000f014,26,26, 1);
}
return PPlus_SUCCESS;
return PPlus_SUCCESS;
#else
return PPlus_ERR_FORBIDDEN;
subWriteReg(0x4000f014,26,26, 0);
return PPlus_ERR_FORBIDDEN;
#endif
}
int hal_pwrmgr_LowCurrentLdo_disable(void)
{
subWriteReg(0x4000f014,26,26, 0);
return PPlus_SUCCESS;
subWriteReg(0x4000f014,26,26, 0);
return PPlus_SUCCESS;
}
extern void gpio_wakeup_set(gpio_pin_e pin, gpio_polarity_e type);
extern void gpio_pull_set(gpio_pin_e pin, gpio_pupd_e type);
void hal_pwrmgr_poweroff(pwroff_cfg_t* pcfg, uint8_t wakeup_pin_num)
{
HAL_ENTER_CRITICAL_SECTION();
subWriteReg(0x4000f01c,6,6,0x00); //disable software control
//(void)(wakeup_pin_num);
HAL_ENTER_CRITICAL_SECTION();
subWriteReg(0x4000f01c,6,6,0x00); //disable software control
//(void)(wakeup_pin_num);
for(uint8_t i = 0; i < wakeup_pin_num; i++ )
{
if(pcfg[i].type==POL_FALLING)
gpio_pull_set(pcfg[i].pin,GPIO_PULL_UP_S);
else
gpio_pull_set(pcfg[i].pin,GPIO_PULL_DOWN);
for(uint8_t i = 0; i < wakeup_pin_num; i++ )
{
if(pcfg[i].type==POL_FALLING)
gpio_pull_set(pcfg[i].pin,GPIO_PULL_UP_S);
else
gpio_pull_set(pcfg[i].pin,GPIO_PULL_DOWN);
gpio_wakeup_set(pcfg[i].pin, pcfg[i].type);
}
gpio_wakeup_set(pcfg[i].pin, pcfg[i].type);
}
/**
config reset casue as RSTC_OFF_MODE
reset path walkaround dwc
*/
/**
config reset casue as RSTC_OFF_MODE
reset path walkaround dwc
*/
AON_CLEAR_XTAL_TRACKING_AND_CALIB;
AP_AON->SLEEP_R[0] = 2;
enter_sleep_off_mode(SYSTEM_OFF_MODE);
AON_CLEAR_XTAL_TRACKING_AND_CALIB;
AP_AON->SLEEP_R[0] = 2;
write_reg(0x4000f000,0x5a5aa5a5);
while(1);
while(1);
}
__ATTR_SECTION_SRAM__ void hal_pwrmgr_enter_sleep_rtc_reset(uint32_t sleepRtcTick)
{
HAL_ENTER_CRITICAL_SECTION();
subWriteReg(0x4000f01c,6,6,0x00); //disable software control
config_RTC(sleepRtcTick);
// clear sram retention
hal_pwrmgr_RAM_retention_clr();
/**
config reset casue as RSTC_WARM_NDWC
reset path walkaround dwc
*/
HAL_ENTER_CRITICAL_SECTION();
subWriteReg(0x4000f01c,6,6,0x00); //disable software control
config_RTC(sleepRtcTick);
// clear sram retention
hal_pwrmgr_RAM_retention_clr();
/**
config reset casue as RSTC_WARM_NDWC
reset path walkaround dwc
*/
AON_CLEAR_XTAL_TRACKING_AND_CALIB;
AP_AON->SLEEP_R[0]=4;
enter_sleep_off_mode(SYSTEM_SLEEP_MODE);
AON_CLEAR_XTAL_TRACKING_AND_CALIB;
AP_AON->SLEEP_R[0]=4;
enter_sleep_off_mode(SYSTEM_SLEEP_MODE);
while(1) {};
while(1) {};
}
#define STANDBY_WAIT_MS(a) WaitRTCCount((a)<<5) // 32us * 32 around 1ms
__attribute__((section("_section_standby_var_"))) pwroff_cfg_t s_pwroff_cfg[WAKEUP_PIN_MAX];
__attribute__((section("_section_standby_var_"))) __attribute__((used)) uint8 pwroff_register_number=0;
#define STANDBY_WAIT_MS(a) WaitRTCCount((a)<<5) // 32us * 32 around 1ms
pwroff_cfg_t s_pwroff_cfg[WAKEUP_PIN_MAX];
__attribute__((used)) uint8 pwroff_register_number=0;
__attribute__((section("_section_standby_code_"))) void wakeupProcess_standby(void)
{
subWriteReg(0x4000f014,29,27,0x07);
STANDBY_WAIT_MS(5);
subWriteReg(0x4000f014,29,27,0x07);
STANDBY_WAIT_MS(5);
#ifdef CFG_FLASH_ENABLE_DEEP_SLEEP
extern void spif_release_deep_sleep(void);
spif_release_deep_sleep();
STANDBY_WAIT_MS(15);
extern void spif_release_deep_sleep(void);
spif_release_deep_sleep();
STANDBY_WAIT_MS(15);
#endif
uint32_t volatile cnt=0;
uint8_t volatile find_flag=0;
uint8 pin_n=0;
extern bool gpio_read(gpio_pin_e pin);
uint32_t volatile cnt=0;
uint8_t volatile find_flag=0;
uint8 pin_n=0;
extern bool gpio_read(gpio_pin_e pin);
for(pin_n=0; pin_n<pwroff_register_number; pin_n++)
{
if((s_pwroff_cfg[pin_n].pin == P2) || (s_pwroff_cfg[pin_n].pin == P3))
{
hal_gpio_pin2pin3_control(s_pwroff_cfg[pin_n].pin,1);
}
}
for(pin_n=0; pin_n<pwroff_register_number; pin_n++)
{
if((s_pwroff_cfg[pin_n].pin == P2) || (s_pwroff_cfg[pin_n].pin == P3))
{
hal_gpio_pin2pin3_control(s_pwroff_cfg[pin_n].pin,1);
}
}
for(pin_n=0; pin_n<pwroff_register_number; pin_n++)
{
if(gpio_read(s_pwroff_cfg[pin_n].pin)==s_pwroff_cfg[pin_n].type)
{
find_flag=1;
break;
}
}
for(pin_n=0; pin_n<pwroff_register_number; pin_n++)
{
if(gpio_read(s_pwroff_cfg[pin_n].pin)==s_pwroff_cfg[pin_n].type)
{
find_flag=1;
break;
}
}
while(1)
{
if(gpio_read(s_pwroff_cfg[pin_n].pin)==s_pwroff_cfg[pin_n].type&&find_flag==1)
{
cnt++;
STANDBY_WAIT_MS(32);
while(1)
{
if(gpio_read(s_pwroff_cfg[pin_n].pin)==s_pwroff_cfg[pin_n].type&&find_flag==1)
{
cnt++;
STANDBY_WAIT_MS(32);
if(cnt>(s_pwroff_cfg[pin_n].on_time>>5))
{
write_reg(0x4000f030, 0x01);
break;
}
}
else
hal_pwrmgr_enter_standby(&s_pwroff_cfg[0],pwroff_register_number);
}
if(cnt>(s_pwroff_cfg[pin_n].on_time>>5))
{
write_reg(0x4000f030, 0x01);
break;
}
}
else
hal_pwrmgr_enter_standby(&s_pwroff_cfg[0],pwroff_register_number);
}
set_sleep_flag(0);
AP_AON->SLEEP_R[0] = 4;
HAL_ENTER_CRITICAL_SECTION();
AP_PCR->SW_RESET1 = 0;
set_sleep_flag(0);
AP_AON->SLEEP_R[0] = 4;
AON_CLEAR_XTAL_TRACKING_AND_CALIB;
HAL_ENTER_CRITICAL_SECTION();
AP_PCR->SW_RESET1 = 0;
while(1);
while(1);
}
extern void gpio_wakeup_set(gpio_pin_e pin, gpio_polarity_e type);
extern void gpio_pull_set(gpio_pin_e pin, gpio_pupd_e type);
__attribute__((section("_section_standby_code_"))) void hal_pwrmgr_enter_standby(pwroff_cfg_t* pcfg,uint8_t wakeup_pin_num)
{
HAL_ENTER_CRITICAL_SECTION();
subWriteReg(0x4000f01c,6,6,0x00); //disable software control
uint8_t i = 0;
HAL_ENTER_CRITICAL_SECTION();
subWriteReg(0x4000f01c,6,6,0x00); //disable software control
uint8_t i = 0;
if(wakeup_pin_num>WAKEUP_PIN_MAX)
{
wakeup_pin_num=WAKEUP_PIN_MAX;
}
if(wakeup_pin_num>WAKEUP_PIN_MAX)
{
wakeup_pin_num=WAKEUP_PIN_MAX;
}
for(i = 0; i < wakeup_pin_num; i++)
{
if(pcfg[i].type==POL_FALLING)
gpio_pull_set(pcfg[i].pin,GPIO_PULL_UP_S);
else
gpio_pull_set(pcfg[i].pin,GPIO_PULL_DOWN);
pwroff_register_number=wakeup_pin_num;
gpio_wakeup_set(pcfg[i].pin, pcfg[i].type);
osal_memcpy(&s_pwroff_cfg[i],&(pcfg[i]),sizeof(pwroff_cfg_t));
pwroff_register_number++;
}
for(i = 0; i < wakeup_pin_num; i++)
{
if(pcfg[i].type==POL_FALLING)
gpio_pull_set(pcfg[i].pin,GPIO_PULL_UP_S);
else
gpio_pull_set(pcfg[i].pin,GPIO_PULL_DOWN);
JUMP_FUNCTION(WAKEUP_PROCESS)= (uint32_t)&wakeupProcess_standby;
gpio_wakeup_set(pcfg[i].pin, pcfg[i].type);
osal_memcpy(&s_pwroff_cfg[i],&(pcfg[i]),sizeof(pwroff_cfg_t));
}
JUMP_FUNCTION(WAKEUP_PROCESS)= (uint32_t)&wakeupProcess_standby;
#ifdef CFG_FLASH_ENABLE_DEEP_SLEEP
extern void spif_set_deep_sleep(void);
spif_set_deep_sleep();
WaitRTCCount(50); // 50*32us
extern void spif_set_deep_sleep(void);
spif_set_deep_sleep();
WaitRTCCount(50);
#endif
subWriteReg(0x4000f014,29,27,0);
set_sleep_flag(1);
AP_AON->SLEEP_R[0] = 2;
subWriteReg(0x4000f01c,21,17,RET_SRAM0);
enter_sleep_off_mode(SYSTEM_SLEEP_MODE);
subWriteReg(0x4000f014,29,27,0);
set_sleep_flag(1);
AP_AON->SLEEP_R[0] = 2;
subWriteReg(0x4000f01c,21,17,RET_SRAM0);
enter_sleep_off_mode(SYSTEM_SLEEP_MODE);
while(1);
while(1);
}
__ATTR_SECTION_XIP__ int hal_pwrmgr_get_module_lock_status(void)
{
if (mPwrMode == PWR_MODE_NO_SLEEP || mPwrMode == PWR_MODE_PWROFF_NO_SLEEP)
{
disableSleep();
return FALSE;
}
for (int i = 0; i < HAL_PWRMGR_TASK_MAX_NUM; i++)
{
if (mCtx[i].lock == TRUE)
{
return FALSE;
}
}
return TRUE;
}

View file

@ -1,8 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/************
pwrmgr.c
SDK_LICENSE
**************/
#ifndef _HAL_PWRMGR_HD
#define _HAL_PWRMGR_HD
@ -14,34 +13,43 @@ extern "C" {
#include "bus_dev.h"
#include "gpio.h"
#include "clock.h"
#define PWR_MODE_NO_SLEEP 1
#define PWR_MODE_SLEEP 2
#define PWR_MODE_PWROFF_NO_SLEEP 4
#define PWR_MODE_NO_SLEEP 1
#define PWR_MODE_SLEEP 2
#define PWR_MODE_PWROFF_NO_SLEEP 4
//WAKEUP FROM STANDBY MODE
#define WAKEUP_PIN_MAX 3
#define WAKEUP_PIN_MAX 3
#define HAL_PWRMGR_TASK_MAX_NUM 10
#define HAL_PWRMGR_TASK_MAX_NUM 10
#define RET_SRAM0 BIT(0) /*32K, 0x1fff0000~0x1fff7fff*/
#define RET_SRAM1 BIT(1) /*16K, 0x1fff8000~0x1fffbfff*/
#define RET_SRAM2 BIT(2) /*16K, 0x1fffc000~0x1fffffff*/
#define RET_SRAM0 BIT(0) /*32K, 0x1fff0000~0x1fff7fff*/
#define RET_SRAM1 BIT(1) /*16K, 0x1fff8000~0x1fffbfff*/
#define RET_SRAM2 BIT(2) /*16K, 0x1fffc000~0x1fffffff*/
#define DEF_CLKG_CONFIG_0 (_CLK_IOMUX|_CLK_UART0|_CLK_GPIO|_CLK_SPIF|_CLK_DMA)
#define DEF_CLKG_CONFIG_0 (_CLK_IOMUX|_CLK_UART0|_CLK_GPIO|_CLK_SPIF|_CLK_DMA|_CLK_TIMER5)
#define DEF_CLKG_CONFIG_1 (_CLK_M0_CPU | _CLK_BB |_CLK_TIMER |_CLK_BBREG \
|_CLK_TIMER1|_CLK_TIMER2|_CLK_TIMER3|_CLK_TIMER4|_CLK_COM)
#define DEF_CLKG_CONFIG_1 (_CLK_M0_CPU | _CLK_BB |_CLK_TIMER |_CLK_BBREG \
|_CLK_TIMER1|_CLK_TIMER2|_CLK_TIMER3|_CLK_TIMER4|_CLK_COM)
typedef struct
{
gpio_pin_e pin;
gpio_polarity_e type;
uint16_t on_time;
gpio_pin_e pin;
gpio_polarity_e type;
uint16_t on_time;
} pwroff_cfg_t;
typedef struct
{
uint8_t sramRet_config:3;
uint8_t moudle_num:5;
} PWRMGR_CFG_BIT;
extern uint32_t g_system_reset_cause;
extern sysclk_t g_system_clk_change;
typedef void (*pwrmgr_Hdl_t)(void);
@ -59,11 +67,16 @@ int hal_pwrmgr_RAM_retention_clr(void);
int hal_pwrmgr_RAM_retention_set(void);
int hal_pwrmgr_LowCurrentLdo_enable(void);
int hal_pwrmgr_LowCurrentLdo_disable(void);
int hal_pwrmgr_get_module_lock_status(void);
void hal_pwrmgr_poweroff(pwroff_cfg_t* pcfg, uint8_t wakeup_pin_num);
__ATTR_SECTION_SRAM__ void hal_pwrmgr_enter_sleep_rtc_reset(uint32_t sleepRtcTick);
void hal_pwrmgr_enter_standby(pwroff_cfg_t* pcfg,uint8_t wakeup_pin_num) ;
void clk_change_mod_restore(void);
extern uint8_t hal_system_clock_change_req(sysclk_t clk);
extern uint8_t hal_system_clock_change_active(sysclk_t clk,pwrmgr_Hdl_t restoreHandle);
#ifdef __cplusplus
}
#endif

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file qdec.c
@brief Contains all functions support for key scan driver
@ -9,7 +5,7 @@
@date 13. Nov. 2017
@author Ding
SDK_LICENSE
*******************************************************************************/
#include "rom_sym_def.h"

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file qdec.h
@brief Contains all functions support for key scan driver
@ -9,7 +5,7 @@
@date 13. Nov. 2017
@author Ding
SDK_LICENSE
*******************************************************************************/
#ifndef __QDEC__H__

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file spi.c
@brief Contains all functions support for spi driver
@ -9,7 +5,7 @@
@date 18. Oct. 2017
@author qing.han
SDK_LICENSE
*******************************************************************************/
#include "rom_sym_def.h"
@ -47,11 +43,20 @@ static spi_Ctx_t m_spiCtx[2];
static void hal_spi_write_fifo(AP_SSI_TypeDef* Ssix,uint8_t len,uint8_t* tx_rx_ptr)
{
uint8_t i=0;
SPI_INDEX_e spi_index = (Ssix == AP_SPI0) ? SPI0 : SPI1;
HAL_ENTER_CRITICAL_SECTION();
while(i<len)
{
Ssix->DataReg = *(tx_rx_ptr+i);
if (m_spiCtx[spi_index].cfg.spi_dfsmod <= SPI_1BYTE)
{
Ssix->DataReg = *(tx_rx_ptr+i);
}
else
{
Ssix->DataReg = *((uint16_t*)tx_rx_ptr+i);
}
i++;
}
@ -114,6 +119,7 @@ static void spi_int_handle(uint8_t id, spi_Ctx_t* pctx, AP_SSI_TypeDef* Ssix)
if(trans_ptr->tx_offset == trans_ptr->xmit_len)
{
Ssix->IMR = 0x10;
m_spiCtx[pctx->spi_info->spi_index].transmit.busy = FALSE;
break;
}
}
@ -448,30 +454,32 @@ static void hal_spi_master_init(hal_spi_t* spi_ptr,uint32_t baud,SPI_SCMOD_e scm
static void config_dma_channel4spitx(hal_spi_t* spi_ptr,uint8_t* tx_buf,uint16_t tx_len)
{
DMA_CH_CFG_t cfgc;
// uint16_t* size16_tx_buf;
AP_SSI_TypeDef* Ssix = NULL;
Ssix = (spi_ptr->spi_index == SPI0) ? AP_SPI0 : AP_SPI1;
Ssix->DMACR &= 0x01;
spi_Ctx_t* pctx;
pctx = &m_spiCtx[spi_ptr->spi_index];
// if(pctx->cfg.spi_dfsmod == SPI_2BYTE)
// size16_tx_buf = (uint16_t *)tx_buf;
cfgc.transf_size = tx_len;
cfgc.sinc = DMA_INC_INC;
if(pctx->cfg.spi_dfsmod == SPI_1BYTE)
if(pctx->cfg.spi_dfsmod <= SPI_1BYTE)
{
hal_spi_dfs_set(spi_ptr,SPI_1BYTE);
cfgc.transf_size = tx_len;
cfgc.src_tr_width = DMA_WIDTH_BYTE;
cfgc.dst_tr_width = DMA_WIDTH_BYTE;
cfgc.src_addr = (uint32_t)tx_buf;
}
else
{
uint16_t* size16_tx_buf = (uint16_t*)tx_buf;
hal_spi_dfs_set(spi_ptr,SPI_2BYTE);
cfgc.transf_size = tx_len/2;
cfgc.src_tr_width = DMA_WIDTH_HALFWORD;
cfgc.dst_tr_width = DMA_WIDTH_HALFWORD;
cfgc.src_addr = (uint32_t)size16_tx_buf;
}
cfgc.src_msize = DMA_BSIZE_1;
cfgc.src_addr = (uint32_t)tx_buf;
cfgc.dinc = DMA_INC_NCHG;
cfgc.dst_msize = DMA_BSIZE_1;
cfgc.dst_addr = (uint32_t)&(Ssix->DataReg);
@ -515,7 +523,7 @@ static int hal_spi_xmit_polling
)
{
uint32_t rx_size = rx_len, tx_size = tx_len;
uint32_t tmp_len,i;
uint32_t tmp_len,i,tmp_tx_buf_len = 0;
AP_SSI_TypeDef* Ssix = NULL;
#if DMAC_USE
spi_Ctx_t* pctx;
@ -557,70 +565,157 @@ static int hal_spi_xmit_polling
if(tx_buf)
{
//support divider 2
switch (tmp_len)
if (m_spiCtx[spi_ptr->spi_index].cfg.spi_dfsmod <= SPI_1BYTE)
{
case 1:
Ssix->DataReg = *tx_buf;
break;
switch (tmp_len)
{
case 1:
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len);
tmp_tx_buf_len += 1;
break;
case 2:
Ssix->DataReg = *tx_buf;
Ssix->DataReg = *(tx_buf+1);
break;
case 2:
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+1);
tmp_tx_buf_len += 2;
break;
case 3:
Ssix->DataReg = *tx_buf;
Ssix->DataReg = *(tx_buf+1);
Ssix->DataReg = *(tx_buf+2);
break;
case 3:
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+1);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+2);
tmp_tx_buf_len += 3;
break;
case 4:
Ssix->DataReg = *tx_buf;
Ssix->DataReg = *(tx_buf+1);
Ssix->DataReg = *(tx_buf+2);
Ssix->DataReg = *(tx_buf+3);
break;
case 4:
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+1);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+2);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+3);
tmp_tx_buf_len += 4;
break;
case 5:
Ssix->DataReg = *tx_buf;
Ssix->DataReg = *(tx_buf+1);
Ssix->DataReg = *(tx_buf+2);
Ssix->DataReg = *(tx_buf+3);
Ssix->DataReg = *(tx_buf+4);
break;
case 5:
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+1);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+2);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+3);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+4);
tmp_tx_buf_len += 5;
break;
case 6:
Ssix->DataReg = *tx_buf;
Ssix->DataReg = *(tx_buf+1);
Ssix->DataReg = *(tx_buf+2);
Ssix->DataReg = *(tx_buf+3);
Ssix->DataReg = *(tx_buf+4);
Ssix->DataReg = *(tx_buf+5);
break;
case 6:
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+1);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+2);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+3);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+4);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+5);
tmp_tx_buf_len += 6;
break;
case 7:
Ssix->DataReg = *tx_buf;
Ssix->DataReg = *(tx_buf+1);
Ssix->DataReg = *(tx_buf+2);
Ssix->DataReg = *(tx_buf+3);
Ssix->DataReg = *(tx_buf+4);
Ssix->DataReg = *(tx_buf+5);
Ssix->DataReg = *(tx_buf+6);
break;
case 7:
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+1);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+2);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+3);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+4);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+5);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+6);
tmp_tx_buf_len += 7;
break;
case 8:
Ssix->DataReg = *tx_buf;
Ssix->DataReg = *(tx_buf+1);
Ssix->DataReg = *(tx_buf+2);
Ssix->DataReg = *(tx_buf+3);
Ssix->DataReg = *(tx_buf+4);
Ssix->DataReg = *(tx_buf+5);
Ssix->DataReg = *(tx_buf+6);
Ssix->DataReg = *(tx_buf+7);
break;
case 8:
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+1);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+2);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+3);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+4);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+5);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+6);
Ssix->DataReg = *(tx_buf+tmp_tx_buf_len+7);
tmp_tx_buf_len += 8;
break;
default:
break;
default:
break;
}
}
else
{
switch (tmp_len)
{
case 1:
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len);
tmp_tx_buf_len += 1;
break;
case 2:
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+1);
tmp_tx_buf_len += 2;
break;
case 3:
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+1);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+2);
tmp_tx_buf_len += 3;
break;
case 4:
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+1);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+2);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+3);
tmp_tx_buf_len += 4;
break;
case 5:
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+1);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+2);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+3);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+4);
tmp_tx_buf_len += 5;
break;
case 6:
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+1);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+2);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+3);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+4);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+5);
tmp_tx_buf_len += 6;
break;
case 7:
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+1);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+2);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+3);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+4);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+5);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+6);
tmp_tx_buf_len += 7;
break;
case 8:
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+1);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+2);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+3);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+4);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+5);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+6);
Ssix->DataReg = *((uint16_t*)tx_buf+tmp_tx_buf_len+7);
tmp_tx_buf_len += 8;
break;
default:
break;
}
}
}
else
@ -720,7 +815,7 @@ void hal_spi_dfs_set(hal_spi_t* spi_ptr,SPI_DFS_e mod)
Ssix->SSIEN = 0;
subWriteReg(&Ssix->CR0,3,0,mod);
Ssix->SSIEN = 1;
pctx->cfg.spi_dfsmod = SPI_2BYTE;
pctx->cfg.spi_dfsmod = mod;
}
@ -939,6 +1034,7 @@ int hal_spi_bus_init(hal_spi_t* spi_ptr,spi_Cfg_t cfg)
hal_clk_gate_enable((MODULE_e)(MOD_SPI0 + spi_ptr->spi_index));
hal_spi_pin_init(spi_ptr,cfg.sclk_pin,cfg.ssn_pin,cfg.MOSI,cfg.MISO);
hal_spi_master_init(spi_ptr,cfg.baudrate, cfg.spi_scmod, cfg.spi_tmod);
hal_spi_dfs_set(spi_ptr,cfg.spi_dfsmod);
pctx->cfg = cfg;
pctx->transmit.busy = false;
pctx->spi_info = spi_ptr;
@ -1075,7 +1171,7 @@ int hal_spi_init(SPI_INDEX_e channel)
}
else if(channel == SPI1)
{
ret = hal_pwrmgr_register(MOD_SPI0,spi1_sleep_handler, spi1_wakeup_handler);
ret = hal_pwrmgr_register(MOD_SPI1,spi1_sleep_handler, spi1_wakeup_handler);
if(ret == PPlus_SUCCESS)
memset(&m_spiCtx[1],0,sizeof(spi_Ctx_t));

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file spi.h
@brief Contains all functions support for spi driver
@ -9,7 +5,7 @@
@date 18. Oct. 2017
@author qing.han
SDK_LICENSE
*******************************************************************************/
#ifndef _SPI_H_
@ -52,11 +48,23 @@ typedef enum
typedef enum
{
SPI_1BYTE=0x07, //1byte
SPI_2BYTE=0x0f, //2byte
} SPI_DFS_e;
SPI_4BIT = 0x03,
SPI_5BIT = 0x04,
SPI_6BIT = 0x05,
SPI_7BIT = 0x06,
SPI_8BIT = 0x07,SPI_1BYTE = 0x07, // 1byte
SPI_9BIT = 0x08,
SPI_10BIT = 0x09,
SPI_11BIT = 0x0a,
SPI_12BIT = 0x0b,
SPI_13BIT = 0x0c,
SPI_14BIT = 0x0d,
SPI_15BIT = 0x0e,
SPI_16BIT = 0x0f,SPI_2BYTE = 0x0f, // 2byte
} SPI_DFS_e;
typedef enum
{
SPI_TRXD=0, //Transmit & Receive

View file

@ -1,6 +1,8 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*************
spiflash.c
SDK_LICENSE
***************/
#include "error.h"
#include "spiflash.h"
#include "log.h"

View file

@ -1,6 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*************
spiflash.h
SDK_LICENSE
***************/
#ifndef __SPIFLASH_H__
#define __SPIFLASH_H__

View file

@ -1,6 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*************
timer.h
SDK_LICENSE
***************/
#include "rom_sym_def.h"
#include "timer.h"
#include "error.h"

View file

@ -1,6 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*************
timer.c
SDK_LICENSE
***************/
#ifndef __TIMER_H__
#define __TIMER_H__

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file uart.c
@brief Contains all functions support for uart driver
@ -9,6 +5,7 @@
@date 19. Oct. 2017
@author qing.han
SDK_LICENSE
*******************************************************************************/
#include "rom_sym_def.h"

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file uart.h
@brief Contains all functions support for uart driver
@ -9,7 +5,7 @@
@date 19. Oct. 2017
@author qing.han
SDK_LICENSE
*******************************************************************************/
#ifndef __UART_H__

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file voice.c
@brief Contains all functions support for adc driver
@ -9,7 +5,7 @@
@date 16. Jun. 2018
@author qing.han
.
SDK_LICENSE
*******************************************************************************/
#include "rom_sym_def.h"

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file voice.h
@brief Contains all functions support for voice driver
@ -9,7 +5,7 @@
@date 18. Jun. 2018
@author qing.han
SDK_LICENSE
*******************************************************************************/
#ifndef __VOICE__H__

View file

@ -1,6 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*************
watchdog.c
SDK_LICENSE
***************/
#include "watchdog.h"
#include "error.h"
#include "clock.h"

View file

@ -1,6 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*************
watchdog.h
SDK_LICENSE
***************/
#ifndef __WATCHDOG_H__
#define __WATCHDOG_H__

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**************************************************************************************************
Filename: bus_dev.h
Revised:
@ -9,6 +5,8 @@
Description: This file contains the SoC MCU relate definitions
SDK_LICENSE
**************************************************************************************************/
#ifndef __BUS_DEV_H__

View file

@ -1,8 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file error.h
@brief Global error definition
@ -10,7 +5,7 @@
@date 11. Feb. 2018
@author Eagle.Lao
SDK_LICENSE
*******************************************************************************/

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**
****************************************************************************************
@ -13,6 +9,8 @@
$Rev: $
SDK_LICENSE
****************************************************************************************
*/

View file

@ -1,7 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/**************************************************************************************************
Filename: bus_dev.h
Revised:
@ -9,6 +5,7 @@
Description: Describe the purpose and contents of the file.
SDK_LICENSE
**************************************************************************************************/

View file

@ -1,6 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*************
mcu_phy_bumbee.h
SDK_LICENSE
***************/
#ifndef __MCU_BUMBEE_M0__
#define __MCU_BUMBEE_M0__

View file

@ -1,6 +1,3 @@
/**************************************************************************************************
*******
**************************************************************************************************/
#ifndef _TYPES_H_
#define _TYPES_H_

View file

@ -1,12 +1,9 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*******************************************************************************
@file sdk_version.h
@brief
@author
SDK_LICENSE
*******************************************************************************/
#ifndef __SDK_VER_H__

View file

@ -1,7 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*************
app_datetime.c
SDK_LICENSE
***************/
#include "phy_console.h"
#include "uart.h"

View file

@ -1,7 +1,7 @@
/**************************************************************************************************
*******
**************************************************************************************************/
/*************
phy_console.h
SDK_LICENSE
***************/
#ifndef _PHY_CONSOLE_H
#define _PHY_CONSOLE_H

Some files were not shown because too many files have changed in this diff Show more