From 9d94fa54d1c4596f9519204f8f76a2a2b77b3e65 Mon Sep 17 00:00:00 2001 From: IOsetting Date: Thu, 30 Dec 2021 09:09:35 +0800 Subject: [PATCH] docs: add license header --- include/fw_cid_stc8g.h | 14 ++++++++++++++ include/fw_cid_stc8h.h | 14 ++++++++++++++ include/fw_conf.h | 4 ++-- include/fw_exti.h | 14 ++++++++++++++ include/fw_gpio.h | 16 +++++++++++++++- include/fw_hal.h | 14 ++++++++++++++ include/fw_mem.h | 14 ++++++++++++++ include/fw_rcc.h | 14 ++++++++++++++ include/fw_sys.h | 16 +++++++++++++++- include/fw_tim.h | 15 +++++++++++++++ include/fw_types.h | 14 ++++++++++++++ include/fw_uart.h | 14 ++++++++++++++ include/fw_util.h | 14 ++++++++++++++ src/fw_exti.c | 14 ++++++++++++++ src/fw_gpio.c | 14 ++++++++++++++ src/fw_mem.c | 14 ++++++++++++++ src/fw_rcc.c | 14 ++++++++++++++ src/fw_sys.c | 30 +++++++++++++++++++++++------- src/fw_tim.c | 15 ++++++++++++++- src/fw_uart.c | 14 ++++++++++++++ src/fw_util.c | 14 ++++++++++++++ 21 files changed, 294 insertions(+), 12 deletions(-) diff --git a/include/fw_cid_stc8g.h b/include/fw_cid_stc8g.h index 268ea5f..e2473e9 100644 --- a/include/fw_cid_stc8g.h +++ b/include/fw_cid_stc8g.h @@ -1,3 +1,17 @@ +// Copyright 2021 IOsetting +// +// 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 __FW_CID_STC8G_H__ #define __FW_CID_STC8G_H__ diff --git a/include/fw_cid_stc8h.h b/include/fw_cid_stc8h.h index 5ce26e8..0a19026 100644 --- a/include/fw_cid_stc8h.h +++ b/include/fw_cid_stc8h.h @@ -1,3 +1,17 @@ +// Copyright 2021 IOsetting +// +// 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 __FW_CID_STC8H_H__ #define __FW_CID_STC8H_H__ diff --git a/include/fw_conf.h b/include/fw_conf.h index 8db4362..d989b69 100644 --- a/include/fw_conf.h +++ b/include/fw_conf.h @@ -59,11 +59,11 @@ #endif #ifndef __CONF_VRTRIM - #define __CONF_VRTRIM 0x20 + #define __CONF_VRTRIM 0x00 #endif #ifndef __CONF_IRTRIM - #define __CONF_IRTRIM 0xC8 + #define __CONF_IRTRIM 0x00 #endif #ifndef __CONF_LIRTRIM diff --git a/include/fw_exti.h b/include/fw_exti.h index e1603fa..b17003d 100644 --- a/include/fw_exti.h +++ b/include/fw_exti.h @@ -1,3 +1,17 @@ +// Copyright 2021 IOsetting +// +// 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 ___FW_EXTI_H___ #define ___FW_EXTI_H___ diff --git a/include/fw_gpio.h b/include/fw_gpio.h index f02b2e7..4e3d810 100644 --- a/include/fw_gpio.h +++ b/include/fw_gpio.h @@ -1,3 +1,17 @@ +// Copyright 2021 IOsetting +// +// 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 ___FW_GPIO_H___ #define ___FW_GPIO_H___ @@ -8,7 +22,7 @@ typedef enum { GPIO_Mode_InOut_QBD = 0x00, /* quasi-bidirectional(be compatible with classical 8051 MCUs) */ GPIO_Mode_Output_PP = 0x01, /* push-pull output */ - GPIO_Mode_Input_HIP = 0x02, /* high-impedance state */ + GPIO_Mode_Input_HIP = 0x02, /* high-impedance input */ GPIO_Mode_Output_OD = 0x03, /* open drain output */ } GPIO_Mode_t; diff --git a/include/fw_hal.h b/include/fw_hal.h index abd6790..fc19bb9 100644 --- a/include/fw_hal.h +++ b/include/fw_hal.h @@ -1,3 +1,17 @@ +// Copyright 2021 IOsetting +// +// 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 ___FW_INC_H___ #define ___FW_INC_H___ diff --git a/include/fw_mem.h b/include/fw_mem.h index 75dafe2..d74cd6b 100644 --- a/include/fw_mem.h +++ b/include/fw_mem.h @@ -1,3 +1,17 @@ +// Copyright 2021 IOsetting +// +// 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 ___FW_MEM_H___ #define ___FW_MEM_H___ diff --git a/include/fw_rcc.h b/include/fw_rcc.h index e53a074..b94cd76 100644 --- a/include/fw_rcc.h +++ b/include/fw_rcc.h @@ -1,3 +1,17 @@ +// Copyright 2021 IOsetting +// +// 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 ___FW_RCC_H___ #define ___FW_RCC_H___ diff --git a/include/fw_sys.h b/include/fw_sys.h index 2393da9..552a24d 100644 --- a/include/fw_sys.h +++ b/include/fw_sys.h @@ -1,3 +1,17 @@ +// Copyright 2021 IOsetting +// +// 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 ___FW_SYS_H___ #define ___FW_SYS_H___ @@ -19,7 +33,7 @@ * 10 External 32KHz | * 11 Internal 32KHz | */ -HAL_StatusTypeDef SYS_Init(void); +void SYS_Init(void); void SYS_Delay(uint16_t t); void SYS_DelayUs(uint16_t t); void SYS_SetSysClkDiv(uint8_t div); diff --git a/include/fw_tim.h b/include/fw_tim.h index a49ceb6..900d700 100644 --- a/include/fw_tim.h +++ b/include/fw_tim.h @@ -1,3 +1,17 @@ +// Copyright 2021 IOsetting +// +// 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 ___FW_TIM_H___ #define ___FW_TIM_H___ @@ -97,6 +111,7 @@ void TIM_Timer2_Config(HAL_State_t freq1t, uint8_t prescaler, uint16_t frequency void TIM_Timer3_Config(HAL_State_t freq1t, uint8_t prescaler, uint16_t frequency, HAL_State_t intState); + /***************************** / * Timer 4 */ diff --git a/include/fw_types.h b/include/fw_types.h index c87ad12..f06dc6e 100644 --- a/include/fw_types.h +++ b/include/fw_types.h @@ -1,3 +1,17 @@ +// Copyright 2021 IOsetting +// +// 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 ___FW_TYPES_H___ #define ___FW_TYPES_H___ diff --git a/include/fw_uart.h b/include/fw_uart.h index 078c4a6..8f3a982 100644 --- a/include/fw_uart.h +++ b/include/fw_uart.h @@ -1,3 +1,17 @@ +// Copyright 2021 IOsetting +// +// 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 ___FW_UART_H___ #define ___FW_UART_H___ diff --git a/include/fw_util.h b/include/fw_util.h index 0e3c5c5..7f28423 100644 --- a/include/fw_util.h +++ b/include/fw_util.h @@ -1,3 +1,17 @@ +// Copyright 2021 IOsetting +// +// 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 ___FW_UTIL_H___ #define ___FW_UTIL_H___ diff --git a/src/fw_exti.c b/src/fw_exti.c index d4450d8..01317ba 100644 --- a/src/fw_exti.c +++ b/src/fw_exti.c @@ -1,2 +1,16 @@ +// Copyright 2021 IOsetting +// +// 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. + #include "fw_exti.h" diff --git a/src/fw_gpio.c b/src/fw_gpio.c index 4439e0f..8125152 100644 --- a/src/fw_gpio.c +++ b/src/fw_gpio.c @@ -1,3 +1,17 @@ +// Copyright 2021 IOsetting +// +// 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. + #include "fw_gpio.h" diff --git a/src/fw_mem.c b/src/fw_mem.c index 1ccb638..68e7945 100644 --- a/src/fw_mem.c +++ b/src/fw_mem.c @@ -1,3 +1,17 @@ +// Copyright 2021 IOsetting +// +// 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. + #include "fw_mem.h" void MEM_SelectWorkRegGroup(MEM_WorkRegGroup_t WorkRegGroup) diff --git a/src/fw_rcc.c b/src/fw_rcc.c index 8aa74a2..f4d5420 100644 --- a/src/fw_rcc.c +++ b/src/fw_rcc.c @@ -1,3 +1,17 @@ +// Copyright 2021 IOsetting +// +// 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. + #include "fw_rcc.h" void RCC_SetSYSCLKSource(RCC_SYSCLKSource_t SYSCLKSource) diff --git a/src/fw_sys.c b/src/fw_sys.c index d6cd9bd..ee52a6f 100644 --- a/src/fw_sys.c +++ b/src/fw_sys.c @@ -1,17 +1,33 @@ +// Copyright 2021 IOsetting +// +// 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. + #include "fw_sys.h" static const uint16_t ticks_ms = (__CONF_FOSC / (float)1000 / 13 - 46); static const uint8_t ticks_us = (__CONF_FOSC / (float)12100000UL); static uint8_t clkdiv = 0x1; -HAL_StatusTypeDef SYS_Init(void) +void SYS_Init(void) { - SYS_SetSysClkDiv(0); - SYS_SetFOSC(__CONF_IRCBAND, __CONF_VRTRIM, __CONF_IRTRIM, __CONF_LIRTRIM); - // Wait a while till sysclk stable, or it may block the main process - uint16_t i = ticks_ms; - while (--i); - return HAL_OK; + if (__CONF_IRCBAND != 0x00 || __CONF_VRTRIM != 0x00 || __CONF_IRTRIM != 0x00) + { + SYS_SetSysClkDiv(0); + SYS_SetFOSC(__CONF_IRCBAND, __CONF_VRTRIM, __CONF_IRTRIM, __CONF_LIRTRIM); + // Wait a while till sysclk stable, or it may block the main process + uint16_t i = ticks_ms; + while (--i); + } } void SYS_Delay(uint16_t t) diff --git a/src/fw_tim.c b/src/fw_tim.c index 8167309..44a86ba 100644 --- a/src/fw_tim.c +++ b/src/fw_tim.c @@ -1,5 +1,18 @@ +// Copyright 2021 IOsetting +// +// 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. + #include "fw_tim.h" -#include "fw_exti.h" #include "fw_sys.h" #include "fw_util.h" diff --git a/src/fw_uart.c b/src/fw_uart.c index 80d470a..aaaa8c0 100644 --- a/src/fw_uart.c +++ b/src/fw_uart.c @@ -1,3 +1,17 @@ +// Copyright 2021 IOsetting +// +// 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. + #include "fw_uart.h" #include "fw_tim.h" #include "fw_sys.h" diff --git a/src/fw_util.c b/src/fw_util.c index 088e618..2e6c49d 100644 --- a/src/fw_util.c +++ b/src/fw_util.c @@ -1,3 +1,17 @@ +// Copyright 2021 IOsetting +// +// 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. + #include "fw_util.h" #include "fw_sys.h"