Skip to content

Commit

Permalink
[hal] prepare to add Air105 support
Browse files Browse the repository at this point in the history
  • Loading branch information
versaloon committed Jul 27, 2023
1 parent f8ca944 commit 2534640
Show file tree
Hide file tree
Showing 20 changed files with 1,212 additions and 0 deletions.
14 changes: 14 additions & 0 deletions script/cmake/targets/Luat/Air105.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
set(VSF_HAL_CHIP_VENDOR Luat)
set(VSF_HAL_CHIP_SERIES Air105)
set(VSF_HAL_CHIP_NAME Air105)

set(VSF_TARGET_DEFINITIONS
"__Luat__"
"__Air105__"

${VSF_TARGET_DEFINITIONS}
)

include(${VSF_CMAKE_ROOT}/targets/arm/__cortex_m4.cmake)

set(VSF_TARGET_PATH ${VSF_SRC_PATH}/hal/driver/${VSF_HAL_CHIP_VENDOR}/${VSF_HAL_CHIP_SERIES})
4 changes: 4 additions & 0 deletions source/hal/driver/Luat/Air105/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
vsf_add_sources(
driver.c
startup_Air105.c
)
37 changes: 37 additions & 0 deletions source/hal/driver/Luat/Air105/__common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*****************************************************************************
* Copyright(C)2009-2022 by VSF Team *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
* *
****************************************************************************/

#ifndef __HAL_DRIVER_LUAT_AIR105_COMMON_H__
#define __HAL_DRIVER_LUAT_AIR105_COMMON_H__

/* \note __common.h should only be included by device.h */

/*============================ INCLUDES ======================================*/

#include "hal/vsf_hal_cfg.h"
#include "hal/arch/vsf_arch.h"

/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ LOCAL VARIABLES ===============================*/
/*============================ INCLUDES ======================================*/
/*============================ PROTOTYPES ====================================*/

#endif
/* EOF */
51 changes: 51 additions & 0 deletions source/hal/driver/Luat/Air105/__device.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*****************************************************************************
* Copyright(C)2009-2022 by VSF Team *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
* *
****************************************************************************/

/*============================ INCLUDES ======================================*/

#include "hal/vsf_hal_cfg.h"

#undef VSF_DEVICE_HEADER

#if defined(__Air105__)
# define VSF_DEVICE_HEADER "./device.h"
#else
# error No supported device found.
#endif

/* include specified device driver header file */
#include VSF_DEVICE_HEADER

#ifdef __VSF_HEADER_ONLY_SHOW_ARCH_INFO__
# ifndef __CPU_ARM__
# define __CPU_ARM__
# endif
#else

#ifndef __HAL_DEVICE_LUAT_AIR105_H__
#define __HAL_DEVICE_LUAT_AIR105_H__

/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ LOCAL VARIABLES ===============================*/
/*============================ PROTOTYPES ====================================*/

#endif // __HAL_DEVICE_LUAT_AIR105_H__
#endif // __VSF_HEADER_ONLY_SHOW_ARCH_INFO__
/* EOF */
34 changes: 34 additions & 0 deletions source/hal/driver/Luat/Air105/common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*****************************************************************************
* Copyright(C)2009-2022 by VSF Team *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
* *
****************************************************************************/

#ifndef __HAL_DRIVER_LUAT_AIR105_COMMON_H__
#define __HAL_DRIVER_LUAT_AIR105_COMMON_H__

/*============================ INCLUDES ======================================*/

#include "hal/vsf_hal_cfg.h"
#include "hal/arch/vsf_arch.h"

/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ LOCAL VARIABLES ===============================*/
/*============================ PROTOTYPES ====================================*/

#endif
/* EOF */
76 changes: 76 additions & 0 deletions source/hal/driver/Luat/Air105/device.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*****************************************************************************
* Copyright(C)2009-2022 by VSF Team *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
* *
****************************************************************************/

/*============================ INCLUDES ======================================*/

#include "hal/vsf_hal_cfg.h"

/*============================ MACROS ========================================*/

#if defined(__VSF_HEADER_ONLY_SHOW_ARCH_INFO__)

/*\note first define basic info for arch. */
//! arch info
# define VSF_ARCH_PRI_NUM 64
# define VSF_ARCH_PRI_BIT 6

// software interrupt provided by a dedicated device
#define VSF_DEV_SWI_NUM 9

#elif defined(__VSF_HAL_SHOW_VENDOR_INFO__)

# ifdef FALSE
# undef FALSE
# endif
# ifdef TRUE
# undef TRUE
# endif

# define __VSF_HEADER_ONLY_SHOW_VENDOR_INFO__
# include "air105.h"

#else

#ifndef __HAL_DEVICE_LUAT_AIR05_H__
#define __HAL_DEVICE_LUAT_AIR05_H__

/*============================ INCLUDES ======================================*/

#include "common.h"

/*============================ MACROS ========================================*/

// software interrupt provided by a dedicated device
#define VSF_DEV_SWI_LIST 28, 30, 31, 34, 41, 43, 44, 45, 48

#define VSF_MUSB_FDRC_PRIV_REG_T
#define VSF_MUSB_FDRC_DYNAMIC_FIFO2

#define USB_OTG_COUNT 1
#define USB_OTG0_CONFIG \
.reg = (void *)0x40000C00, \
.irqn = 1,

/*============================ MACROFIED FUNCTIONS ===========================*/
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/
/*============================ LOCAL VARIABLES ===============================*/
/*============================ PROTOTYPES ====================================*/

#endif // __HAL_DEVICE_LUAT_AIR05_H__
#endif // __VSF_HEADER_ONLY_SHOW_ARCH_INFO__
/* EOF */
80 changes: 80 additions & 0 deletions source/hal/driver/Luat/Air105/driver.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*****************************************************************************
* Copyright(C)2009-2022 by VSF Team *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
* *
****************************************************************************/

/*============================ INCLUDES ======================================*/

#include "hal/vsf_hal_cfg.h"

#ifdef FALSE
# undef FALSE
#endif
#ifdef TRUE
# undef TRUE
#endif
#include "air105.h"
#undef CRC

#include "global_config.h"

#include "./device.h"
#include "./driver.h"

/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
/*============================ TYPES =========================================*/
/*============================ GLOBAL VARIABLES ==============================*/

uint32_t SystemCoreClock;

/*============================ LOCAL VARIABLES ===============================*/
/*============================ PROTOTYPES ====================================*/
/*============================ IMPLEMENTATION ================================*/

#include "hal/driver/common/swi/arm/vsf_swi_template.inc"

int vsf_hal_pre_startup_init(void)
{
// seems systick is not reset on hw reset of aic8800
// avoid systick interrupt before os started
SysTick->CTRL = 0;
return 1;
}

/*! \note initialize device driver
* \param none
* \retval true initialization succeeded.
* \retval false initialization failed
*/
WEAK(vsf_driver_init)
bool vsf_driver_init(void)
{
//SystemInit();
SYSCTRL->CG_CTRL1 = SYSCTRL_APBPeriph_ALL;
SYSCTRL->SOFT_RST1 = SYSCTRL_APBPeriph_ALL;
SYSCTRL->SOFT_RST2 &= ~SYSCTRL_USB_RESET;
SYSCTRL->LOCK_R |= SYSCTRL_USB_RESET;
SYSCTRL->LDO25_CR &= ~(VSF_BIT(4) | VSF_BIT(5));
BPU->SEN_ANA0 |= (7 << 25) | (2 << 29);

//SystemCoreClockUpdate();
SystemCoreClock = HSE_VALUE * (((SYSCTRL->FREQ_SEL & SYSCTRL_FREQ_SEL_XTAL_Mask) >> SYSCTRL_FREQ_SEL_XTAL_Pos) + 1);

return true;
}


/* EOF */
42 changes: 42 additions & 0 deletions source/hal/driver/Luat/Air105/driver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*****************************************************************************
* Copyright(C)2009-2022 by VSF Team *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
* *
****************************************************************************/

#if defined(__VSF_HEADER_ONLY_SHOW_ARCH_INFO__) || defined(__VSF_HAL_SHOW_VENDOR_INFO__)

# include "__device.h"

#else

#ifndef __HAL_DRIVER_LUAT_AIR05_H__
#define __HAL_DRIVER_LUAT_AIR05_H__

/*============================ INCLUDES ======================================*/

# include "hal/vsf_hal_cfg.h"
# include "./device.h"

# include "./usb/usb.h"

/*============================ MACROFIED FUNCTIONS ===========================*/
/*============================ TYPES =========================================*/
/*============================ INCLUDES ======================================*/
/*============================ TYPES =========================================*/
/*============================ INCLUDES ======================================*/

# endif // __HAL_DRIVER_LUAT_AIR05_H__
#endif // __VSF_HEADER_ONLY_SHOW_ARCH_INFO__
/* EOF */
Loading

0 comments on commit 2534640

Please sign in to comment.