fix copyright issue

Signed-off-by: haobo <haobo@chipsea.com>
This commit is contained in:
chiptest
2022-12-30 14:41:46 +08:00
parent 9f3bb2a54b
commit 9b4dbfaefa
16 changed files with 116 additions and 4346 deletions
+3 -1
View File
@@ -37,6 +37,7 @@ module_group(module_name) {
"sdk/bsp/driver/gpio",
"sdk/bsp/driver/iomux",
"sdk/bsp/driver/ipc",
"sdk/bsp/driver/pub",
"sdk/bsp/driver/pmic",
"sdk/bsp/driver/psim",
"sdk/bsp/driver/reg",
@@ -45,7 +46,8 @@ module_group(module_name) {
"sdk/bsp/driver/stdio_uart",
"sdk/bsp/driver/sysctrl",
"sdk/bsp/driver/ticker",
"sdk/bsp/driver/time",
#"sdk/bsp/driver/time",
"sdk/bsp/driver/trng",
"sdk/bsp/wrapper",
@@ -1,4 +1,4 @@
/*
/* mbed Microcontroller Library
* Copyright (c) 2014-2018 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
+1 -1
View File
@@ -34,7 +34,7 @@
#include <stddef.h> // standard definitions
#include <stdint.h> // standard integer definition
#include <stdbool.h> // boolean definition
#include "time_api.h"
#include "driver_pub.h"
#include "dbg.h"
@@ -12,10 +12,12 @@
# limitations under the License.
import("//kernel/liteos_m/liteos.gni")
module_name = "bsp_sdk_time"
module_name = "bsp_sdk_public"
print("SOC:CHIPSEA:CST85/liteos_m/sdk - $module_name")
kernel_module(module_name) {
sources = [ "time_api.c" ]
sources = []
include_dirs = []
}
config("public") {
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., Ltd. All rights reserved.
* 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 DRIVER_PUBLIC_H
#define DRIVER_PUBLIC_H
/*chipsea_ohos proguard begin*/
#include "cs_proguard.h"
/*chipsea_ohos proguard end*/
#include <time.h>
#define TIME_FUNC_GRP_0_IMPL 1
#define TIME_FUNC_GRP_1_IMPL 0
enum time_origin_t {
/** Since boot time */
SINCE_BOOT,
/** Since Epoch : 1970-01-01 00:00:00 +0000 (UTC) */
SINCE_EPOCH,
};
#if TIME_FUNC_GRP_0_IMPL
#define YEAR0 1900
#define EPOCH_YEAR 1970
struct tm* gmtime_offset_r(const time_t* timer, struct tm *st_time, int offset);
time_t mk_gmtime_offset_r(const struct tm *st_time, int offset);
#endif
void cs_time_init(uint32_t sec, uint32_t usec);
void cs_time_update(uint32_t sec, uint32_t usec);
int cs_time_get(enum time_origin_t origin, uint32_t *sec, uint32_t *usec);
int cs_time_us_get(enum time_origin_t origin, uint64_t *usec);
#endif
@@ -1,476 +0,0 @@
/*
* Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., Ltd. All rights reserved.
* 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.
*/
/**
****************************************************************************************
*
* @file time_api.c
*
****************************************************************************************
*/
/**
****************************************************************************************
* @addtogroup TIME
* @{
****************************************************************************************
*/
/*chipsea_ohos proguard begin*/
#include "cs_proguard.h"
/*chipsea_ohos proguard end*/
#include "time_api.h"
#define USE_LP_TICKER_READ 1
#define USE_RTOS_TICKCOUNT 0
#if USE_LP_TICKER_READ
#include "lp_ticker_api.h"
#elif USE_RTOS_TICKCOUNT
#include "rtos_ohos_al.h"
#endif
static uint32_t epoch_sec;
static uint32_t epoch_usec;
#if USE_LP_TICKER_READ
static const ticker_data_t *lp_tick_d = NULL;
#endif /* USE_LP_TICKER_READ */
void cs_time_init(uint32_t sec, uint32_t usec)
{
epoch_sec = sec;
epoch_usec = usec;
#if USE_LP_TICKER_READ
if (lp_tick_d == NULL) {
lp_tick_d = get_lp_ticker_data();
ticker_read_us(lp_tick_d);
}
#endif /* USE_LP_TICKER_READ */
}
void cs_time_update(uint32_t sec, uint32_t usec)
{
#if USE_LP_TICKER_READ
if (lp_tick_d == NULL) {
cs_time_init(sec, usec);
} else {
uint64_t cur_us = ticker_read_us(lp_tick_d);
uint64_t epo_us = ((uint64_t)sec) * 1000000 + usec - cur_us;
uint32_t msb, lsb, _sec, _usec, tmp, fact = 0x8637bd;
/* 52bits time value is divided in 5 parts 0xABBCCDDDDEEEE
factor = 0x8637bd = 1 / 1000000 in Q43 = ((1<<43) / 1000000) */
msb = (uint32_t)(epo_us >> 32);
lsb = (uint32_t)epo_us;
tmp = ((msb >> 8) & 0xff) * fact;
_sec = (tmp >> 3);
tmp = (msb & 0xff) * fact;
_sec += (tmp >> 11);
fact >>= 1;
tmp = (msb >> 16) * fact;
_sec += (tmp << 6);
fact >>= 7;
tmp = (lsb >> 16) * fact;
_sec += (tmp >> 19);
_usec = lsb - (_sec * 1000000);
epoch_sec = _sec;
epoch_usec = _usec;
}
#endif /* USE_LP_TICKER_READ */
}
/**
****************************************************************************************
* @brief Read two part monotic counter 2
*
* Read msb twice to detect if counter wrap while reading it.
*
* @param[out] msb Updated with msb part of the counter (16bits only)
* @param[out] lsb Updated with lsb part of the counter (32bits)
****************************************************************************************
*/
void cs_time_read(uint32_t *msb, uint32_t *lsb)
{
#if USE_LP_TICKER_READ
uint64_t cur_us = ticker_read_us(lp_tick_d);
*msb = (uint32_t)(cur_us >> 32);
*lsb = (uint32_t)cur_us;
#elif USE_RTOS_TICKCOUNT
uint64_t cur_us = rtos_now(false) * 1000;
*msb = (uint32_t)(cur_us >> 32);
*lsb = (uint32_t)cur_us;
#endif
}
int cs_time_get(enum time_origin_t origin, uint32_t *sec, uint32_t *usec)
{
uint32_t msb, lsb, _sec, _usec, tmp, fact;
if (origin > SINCE_EPOCH)
return -1;
cs_time_read(&msb, &lsb);
/* Replace uint64_t / 1000000 (uint48_t in practice)
by 3 ~fmul (mul + shift).
Yes this is more complicated but also 20 times faster on cpu without div
instruction.
48bits time value is divided in 4 parts 0xAABBCCCCDDDD
First two parts (A ,B) are only 8bits to allow more bits in the factor
(merging this two parts with a 16 bits factor doesn't provide enough precision).
For the third part (C) a factor on 16bits is enough so part is also 16bits.
Fourth part (D) is always < 1000000 so no need to divide it.
factor = 0x8637bd = 1 / 1000000 in Q43 = ((1<<43) / 1000000) (truncated on 24bits)
*/
fact = 0x8637bd;
tmp = (msb >> 8) * fact;
_sec = (tmp >> 3);
tmp = (msb & 0xff) * fact;
_sec += (tmp >> 11);
fact >>= 8;
tmp = (lsb >> 16) * fact;
_sec += (tmp >> 19);
_usec = lsb - (_sec * 1000000);
if (origin == SINCE_EPOCH)
{
_sec += epoch_sec;
_usec += epoch_usec;
}
/* Previous computation ensure that loop won't run more than 2 times */
while (_usec > 1000000)
{
_usec -= 1000000;
_sec ++;
}
*sec = _sec;
*usec = _usec;
return 0;
}
int cs_time_us_get(enum time_origin_t origin, uint64_t *usec)
{
uint32_t msb, lsb;
uint64_t val;
if (origin > SINCE_EPOCH)
return -1;
cs_time_read(&msb, &lsb);
val = ((uint64_t)msb << 32) + (uint64_t)lsb;
if (origin == SINCE_EPOCH)
{
val += (uint64_t)epoch_usec;
val += (uint64_t)(epoch_sec * 1000000);
}
*usec = val;
return 0;
}
#if TIME_FUNC_GRP_0_IMPL
#define SECS_DAY (24L * 60L * 60L)
#define LEAPYEAR(year) (!((year) % 4) && (((year) % 100) || !((year) %400)))
#define YEARSIZE(year) (LEAPYEAR(year) ? 366 : 365)
struct tm* gmtime_offset_r(const time_t* timer, struct tm *st_time, int offset)
{
static const int _ytab[2][12] =
{
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
};
struct tm* ret = st_time;
time_t secs = *timer + (offset * 60L * 60L);
unsigned long dayclock, dayno;
int year = EPOCH_YEAR;
dayclock = (unsigned long)secs % SECS_DAY;
dayno = (unsigned long)secs / SECS_DAY;
ret->tm_sec = (int) dayclock % 60;
ret->tm_min = (int)(dayclock % 3600) / 60;
ret->tm_hour = (int) dayclock / 3600;
ret->tm_wday = (int) (dayno + 4) % 7; /* day 0 a Thursday */
while(dayno >= (unsigned long)YEARSIZE(year)) {
dayno -= YEARSIZE(year);
year++;
}
ret->tm_year = year - YEAR0;
ret->tm_yday = (int)dayno;
ret->tm_mon = 0;
while(dayno >= (unsigned long)_ytab[LEAPYEAR(year)][ret->tm_mon]) {
dayno -= _ytab[LEAPYEAR(year)][ret->tm_mon];
ret->tm_mon++;
}
ret->tm_mon++;
ret->tm_mday = (int)++dayno;
ret->tm_isdst = 0;
return ret;
}
time_t mk_gmtime_offset_r(const struct tm *st_time, int offset)
{
/* Get year AD. */
int i4_year = YEAR0 + st_time->tm_year; /* 20xx */
/* Get month zero-based. */
int i4_month = st_time->tm_mon; /* 0..11 */
uint32_t u4_days;
uint32_t u4_result;
u4_days = st_time->tm_mday - 1; /* 1..31 */
/* Make March the first month. */
i4_month -= 2;
if (i4_month < 0) {
/* January or February: leap day has yet to come for this year. */
i4_year--;
i4_month += 12;
}
/* Add the number of days past until this month. */
u4_days += ((306 * i4_month) + 5) / 10;
/* Add days past before this year: */
u4_days +=
+ (i4_year * 365) /* Every normal year. */
+ (i4_year / 4) /* Plus a day for every leap year. */
- (i4_year / 100) /* Minus the centuries. */
+ (i4_year / 400) /* Except every fourth century. */
- ((1970 * 365) + (1970 / 4) - (1970 / 100) + (1970 / 400)) /* Minus the days before 1-1-1970 */
+ (59); /* Because 2 months were subtracted. */
u4_result =
(u4_days * SECS_DAY) +
(st_time->tm_hour * (60 * 60)) +
(st_time->tm_min * 60) +
st_time->tm_sec - (offset * 60 * 60);
return u4_result;
}
#endif /* TIME_FUNC_GRP_0_IMPL */
#if TIME_FUNC_GRP_1_IMPL
#define SECONDS_PER_MINUTE ( 60 )
#define MINUTES_PER_HOUR ( 60 )
#define HOURS_PER_DAY ( 24 )
#define SECONDS_PER_HOUR ( MINUTES_PER_HOUR * SECONDS_PER_MINUTE )
#define SECONDS_PER_DAY ( HOURS_PER_DAY * SECONDS_PER_HOUR )
/* The first weekday in 'FF_TimeStruct_t' is Sunday. */
#define WEEK_DAY_SUNDAY 0
#define WEEK_DAY_MONNDAY 1
#define WEEK_DAY_TUESDAY 2
#define WEEK_DAY_WEDNESDAY 3
#define WEEK_DAY_THURSDAY 4
#define WEEK_DAY_FRIDAY 5
#define WEEK_DAY_SATURDAY 6
/* Make a bitmask with a '1' for each 31-day month. */
#define _MM(month) ( 1u << ( month - 1 ) )
#define MASK_LONG_MONTHS ( _MM(1) | _MM(3) | _MM(5) | _MM(7) | _MM(8) | _MM(10) | _MM(12) )
#define DAYS_UNTIL_1970 ( ( 1970 * 365 ) + ( 1970 / 4 ) - ( 1970 / 100 ) + ( 1970 / 400 ) )
#define DAYS_BEFORE_MARCH ( 59 )
__STATIC_INLINE int iIsLeapyear( int iYear )
{
int iReturn;
if( ( iYear % 4 ) != 0 )
{
/* Not a multiple of 4 years. */
iReturn = 0;
}
else if( ( iYear % 400 ) == 0 )
{
/* Every 4 centuries there is a leap year */
iReturn = 1;
}
else if( ( iYear % 100 ) == 0 )
{
/* Other centuries are not a leap year */
iReturn = 0;
}
else
{
/* Otherwise every fourth year. */
iReturn = 1;
}
return iReturn;
}
__STATIC_INLINE unsigned long ulDaysPerYear( int iYear )
{
int iDays;
if( iIsLeapyear( iYear ) )
{
iDays = 366;
}
else
{
iDays = 365;
}
return iDays;
}
static int iDaysPerMonth( int iYear, int iMonth )
{
int iDays;
/* Month is zero-based, 1 is February. */
if (iMonth != 1 )
{
/* 30 or 31 days? */
if( ( MASK_LONG_MONTHS & ( 1u << iMonth ) ) != 0 )
{
iDays = 31;
}
else
{
iDays = 30;
}
}
else if( iIsLeapyear( iYear ) == 0 )
{
/* February, non leap year. */
iDays = 28;
}
else
{
/* February, leap year. */
iDays = 29;
}
return iDays;
}
FF_TimeStruct_t *FreeRTOS_gmtime_r( const time_t *pxTime, FF_TimeStruct_t *pxTimeBuf )
{
time_t xTime = *pxTime;
unsigned long ulDaySeconds, ulDayNumber;
int iYear = GMTIME_FIRST_YEAR;
int iMonth;
/* Clear all fields, some might not get set here. */
memset( ( void * )pxTimeBuf, '\0', sizeof( *pxTimeBuf ) );
/* Seconds since last midnight. */
ulDaySeconds = ( unsigned long ) ( xTime % SECONDS_PER_DAY ) ;
/* Days since 1 Jan 1970. */
ulDayNumber = ( unsigned long ) ( xTime / SECONDS_PER_DAY ) ;
/* Today's HH:MM:SS */
pxTimeBuf->tm_hour = ulDaySeconds / SECONDS_PER_HOUR;
pxTimeBuf->tm_min = ( ulDaySeconds % SECONDS_PER_HOUR ) / 60;
pxTimeBuf->tm_sec = ulDaySeconds % 60;
/* Today's week day, knowing that 1-1-1970 was a THursday. */
pxTimeBuf->tm_wday = ( ulDayNumber + WEEK_DAY_THURSDAY ) % 7;
for( ; ; )
{
/* Keep subtracting 365 (or 366) days while possible. */
unsigned long ulDays = ulDaysPerYear( iYear );
if( ulDayNumber < ulDays )
{
break;
}
ulDayNumber -= ulDays;
iYear++;
}
/* Subtract 1900. */
pxTimeBuf->tm_year = iYear - TM_STRUCT_FIRST_YEAR;
/* The day within this year. */
pxTimeBuf->tm_yday = ulDayNumber;
/* Month are counted as 0..11 */
iMonth = 0;
for( ; ; )
{
unsigned long ulDays = iDaysPerMonth( iYear, iMonth );
/* Keep subtracting 30 (or 28, 29, or 31) days while possible. */
if( ulDayNumber < ulDays )
{
break;
}
ulDayNumber -= ulDays;
iMonth++;
}
pxTimeBuf->tm_mon = iMonth;
/* Month days are counted as 1..31 */
pxTimeBuf->tm_mday = ulDayNumber + 1;
return pxTimeBuf;
}
time_t FreeRTOS_mktime( const FF_TimeStruct_t *pxTimeBuf )
{
/* Get year AD. */
int iYear = 1900 + pxTimeBuf->tm_year; /* 20xx */
/* Get month zero-based. */
int iMonth = pxTimeBuf->tm_mon; /* 0..11 */
uint32_t ulDays;
uint32_t ulResult;
ulDays = pxTimeBuf->tm_mday - 1; /* 1..31 */
/* Make March the first month. */
iMonth -= 2;
if( iMonth < 0 )
{
/* January or February: leap day has yet to come for this year. */
iYear--;
iMonth += 12;
}
/* Add the number of days past until this month. */
ulDays += ( ( 306 * iMonth ) + 5 ) / 10;
/* Add days past before this year: */
ulDays +=
+ ( iYear * 365 ) /* Every normal year. */
+ ( iYear / 4 ) /* Plus a day for every leap year. */
- ( iYear / 100 ) /* Minus the centuries. */
+ ( iYear / 400 ) /* Except every fourth century. */
- ( DAYS_UNTIL_1970 ) /* Minus the days before 1-1-1970 */
+ ( DAYS_BEFORE_MARCH );/* Because 2 months were subtracted. */
ulResult =
( ulDays * SECONDS_PER_DAY ) +
( pxTimeBuf->tm_hour * SECONDS_PER_HOUR ) +
( pxTimeBuf->tm_min * SECONDS_PER_MINUTE ) +
pxTimeBuf->tm_sec;
return ulResult;
}
#endif /* TIME_FUNC_GRP_1_IMPL */
/**
* @}
*/
@@ -1,164 +0,0 @@
/*
* Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., Ltd. All rights reserved.
* 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.
*/
/**
****************************************************************************************
*
* @file time_api.h
*
****************************************************************************************
*/
#ifndef _TIME_API_H_
#define _TIME_API_H_
/*chipsea_ohos proguard begin*/
#include "cs_proguard.h"
/*chipsea_ohos proguard end*/
#include "arch.h"
#include <time.h>
#define TIME_FUNC_GRP_0_IMPL 1
#define TIME_FUNC_GRP_1_IMPL 0
/**
****************************************************************************************
* @defgroup TIME TIME
* @ingroup PLATFORM_DRIVERS
* @{
****************************************************************************************
*/
/**
* Time origin
*/
enum time_origin_t {
/** Since boot time */
SINCE_BOOT,
/** Since Epoch : 1970-01-01 00:00:00 +0000 (UTC) */
SINCE_EPOCH,
};
/**
****************************************************************************************
* @brief Initialize time.
*
* @param[in] sec Number of seconds since Epoch when the system started.
* @param[in] usec Number of microseconds since Epoch when the system started
* (excluding the seconds in sec).
****************************************************************************************
*/
void cs_time_init(uint32_t sec, uint32_t usec);
/**
****************************************************************************************
* @brief Update time.
*
* @param[in] sec Number of seconds since Epoch when the system started.
* @param[in] usec Number of microseconds since Epoch when the system started
* (excluding the seconds in sec).
****************************************************************************************
*/
void cs_time_update(uint32_t sec, uint32_t usec);
/**
****************************************************************************************
* @brief Get current time.
*
* return the current time, from the selected origin, in a sec/usec split.
*
* @param[in] origin Select the time origin (Since boot or since Epoch)
* @param[out] sec Udapted with the number of seconds since the selected origin.
* @param[out] usec Updated with the number of microseconds since the selected origin.
* (excluding the seconds in sec)
*
* @return 0 on success and != 0 otherwise.
****************************************************************************************
*/
int cs_time_get(enum time_origin_t origin, uint32_t *sec, uint32_t *usec);
/**
****************************************************************************************
* @brief Get current time.
*
* return the current time, from the selected origin, in usec.
*
* @param[in] origin Select the time origin (Since boot or since Epoch)
* @param[out] usec Updated with the number of microseconds since the selected origin.
*
* @return 0 on success and != 0 otherwise.
****************************************************************************************
*/
int cs_time_us_get(enum time_origin_t origin, uint64_t *usec);
#if TIME_FUNC_GRP_0_IMPL
#if 0
/* user time, and gmtime compatible functions, there is a gmtime
implementation here that WINCE uses, so really just need some ticks
since the EPOCH
*/
struct tm {
int tm_sec; /* seconds after the minute [0-60] */
int tm_min; /* minutes after the hour [0-59] */
int tm_hour; /* hours since midnight [0-23] */
int tm_mday; /* day of the month [1-31] */
int tm_mon; /* months since January [0-11] */
int tm_year; /* years since 1900 */
int tm_wday; /* days since Sunday [0-6] */
int tm_yday; /* days since January 1 [0-365] */
int tm_isdst; /* Daylight Savings Time flag */
long tm_gmtoff; /* offset from CUT in seconds */
char *tm_zone; /* timezone abbreviation */
};
typedef long time_t;
#endif
#define YEAR0 1900
#define EPOCH_YEAR 1970
struct tm* gmtime_offset_r(const time_t* timer, struct tm *st_time, int offset);
time_t mk_gmtime_offset_r(const struct tm *st_time, int offset);
#endif /* TIME_FUNC_GRP_0_IMPL */
#if TIME_FUNC_GRP_1_IMPL
/* _HT_
The following declarations and functions may be moved to a common directory?
*/
typedef struct xTIME_STRUCT
{
int tm_sec; /* Seconds */
int tm_min; /* Minutes */
int tm_hour; /* Hour (0--23) */
int tm_mday; /* Day of month (1--31) */
int tm_mon; /* Month (0--11) */
int tm_year; /* Year (calendar year minus 1900) */
int tm_wday; /* Weekday (0--6; Sunday = 0) */
int tm_yday; /* Day of year (0--365) */
int tm_isdst; /* 0 if daylight savings time is not in effect) */
} FF_TimeStruct_t;
#define GMTIME_FIRST_YEAR ( 1970 )
#define TM_STRUCT_FIRST_YEAR ( 1900 )
/* Equivalent of gmtime_r() : Fills a 'struct tm'. */
FF_TimeStruct_t *FreeRTOS_gmtime_r( const time_t *pxTime, FF_TimeStruct_t *pxTimeBuf );
/* Equivalent of mktime() : calculates the number of seconds after 1-1-1970. */
time_t FreeRTOS_mktime( const FF_TimeStruct_t *pxTimeBuf );
#endif /* TIME_FUNC_GRP_1_IMPL */
/**
* @}
*/
#endif /* _TIME_API_H_ */
Binary file not shown.
+37 -157
View File
@@ -1,182 +1,62 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., Ltd. All rights reserved.
* 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
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* http://www.apache.org/licenses/LICENSE-2.0
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Description: Provide a task example.
* 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.
*/
// define CFG_DBG to use dbg interface.
#define CFG_DBG 1
#include "task_sample.h"
//#include "Led_service.h"
#include "los_config.h"
#include "los_debug.h"
#include "los_interrupt.h"
#include "los_task.h"
#include "los_tick.h"
//#include "gpio.h"
#include "dbg.h"
//#include "hdf_log.h"
/*
#define HDF_LED_SERVICE "led_driver"
static struct LedService *GetLedService()
{
static struct LedService *service = NULL;
if (service == NULL) {
struct LedService *LedCntlr = (struct LedService *)DevSvcManagerClntGetService(HDF_LED_SERVICE);
if (LedCntlr == NULL) {
HDF_LOGE("failed to get service %s", HDF_LED_SERVICE);
dbgprint("failed to get service\r\n");
return NULL;
}
// service = (struct LedService *)LedCntlr->priv; //
service = (struct LedService *)LedCntlr; //
}
return service;
}
void LedSet(void)
{
struct LedService *service = GetLedService();
if (service == NULL || service->setData == NULL) {
HDF_LOGE("failed to set data %s", HDF_LED_SERVICE);
dbgprint("failed to set data\r\n");
return;
}
service->setData();
}
*/
VOID TaskSampleEntry2(VOID)
{
//led_init();
void sample_task_entry1(void) {
while (1) {
dbgprint("\r\nTaskSampleEntry2 runing\r\n");
printf("%s: sample_task_entry1 runing\r\n", __func__);
LOS_TaskDelay(1000);
}
}
//LVGL UI界面
VOID TaskSampleEntry1(VOID)
{
#if 0
int cnt = 0;
#if 1
timer1_init();
dbgprint("___>>>>>> %s %d\r\n", __FILE__, __LINE__);
/* configure the EXMC access mode */
exmc_lcd_init();
dbgprint("___>>>>>> %s %d\r\n", __FILE__, __LINE__);
/* configure the GPIO of SPI touch panel */
touch_panel_gpio_configure();
dbgprint("___>>>>>> %s %d\r\n", __FILE__, __LINE__);
/* initialize the LCD */
lcd_init();
dbgprint("___>>>>>> %s %d\r\n", __FILE__, __LINE__);
lv_init(); //lvgl 系统初始化
lv_port_disp_init(); //lvgl 显示接口初始化,放在 lv_init()的后面
lv_port_indev_init(); //lvgl 输入接口初始化,放在 lv_init()的后面
dbgprint("___>>>>>> %s %d\r\n", __FILE__, __LINE__);
lv_ui_home_demo(500);
dbgprint("___>>>>>> %s %d\r\n", __FILE__, __LINE__);
void sample_task_entry2(void) {
while (1) {
LOS_TaskDelay(1); /* 2 Seconds */
lv_task_handler();
}
#endif
#endif
//DeviceManagerStart();
//OHOS_SystemInit();
while (1) {
dbgprint("\r\nTaskSampleEntry1 runing\r\n");
//LedSet();
printf("%s: sample_task_entry2 runing\r\n", __func__);
LOS_TaskDelay(1000);
}
}
VOID TaskSample(VOID)
{
UINT32 uwRet;
UINT32 taskID1;
UINT32 taskID2;
TSK_INIT_PARAM_S stTask = {0};
stTask.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskSampleEntry1;
stTask.uwStackSize = 0x1000;
stTask.pcName = "TaskSampleEntry1";
stTask.usTaskPrio = 6; /* Os task priority is 6 */
uwRet = LOS_TaskCreate(&taskID1, &stTask);
if (uwRet != LOS_OK) {
dbgprint("\r\nTask1 create failed\r\n");
}
stTask.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskSampleEntry2;
stTask.uwStackSize = 0x1000;
stTask.pcName = "TaskSampleEntry2";
stTask.usTaskPrio = 7; /* Os task priority is 7 */
uwRet = LOS_TaskCreate(&taskID2, &stTask);
if (uwRet != LOS_OK) {
dbgprint("\r\nTask2 create failed\r\n");
}
}
VOID RunTaskSample(VOID)
{
void create_task(void) {
UINT32 ret;
ret = LOS_KernelInit();
TSK_INIT_PARAM_S sample_task1 = {0};
TSK_INIT_PARAM_S sample_task2 = {0};
UINT32 sample_taskid1;
UINT32 sample_taskid2;
dbgprint("\r\n\13510979604\r\n");
dbgprint("\r\nOpen Harmony 3.0 start ...\r\n\r\n");
if (ret == LOS_OK) {
TaskSample();
//启动OpenHarmony OS 内核
dbgprint("\r\n create task ok\r\n");
dbgprint("\r\n start task \r\n");
LOS_Start();
sample_task1.pfnTaskEntry = (TSK_ENTRY_FUNC)sample_task_entry1;
sample_task1.uwStackSize = 0x1000;
sample_task1.pcName = "sample_task_entry1";
sample_task1.usTaskPrio = 6; /* Os task priority is 6 */
ret = LOS_TaskCreate(&sample_task1, &sample_task1);
if (ret != LOS_OK) {
printf("%s: sample task1 create failed!\r\n", __func__);
}
sample_task2.pfnTaskEntry = (TSK_ENTRY_FUNC)sample_task_entry2;
sample_task2.uwStackSize = 0x1000;
sample_task2.pcName = "sample_task_entry2";
sample_task2.usTaskPrio = 6; /* Os task priority is 6 */
ret = LOS_TaskCreate(&sample_task2, &sample_task2);
if (ret != LOS_OK) {
printf("%s: sample task2 create failed!\r\n", __func__);
}
printf("%s: sample tasks create ok.\r\n", __func__);
}
+11 -30
View File
@@ -1,36 +1,17 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., Ltd. All rights reserved.
* 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
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* http://www.apache.org/licenses/LICENSE-2.0
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*
* Description: Provide a task example.
* 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 _TASKSAMPLE_H
#define _TASKSAMPLE_H
@@ -42,7 +23,7 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
VOID RunTaskSample(VOID);
void create_task(void);
#ifdef __cplusplus
#if __cplusplus
@@ -26,7 +26,7 @@
#include "app_tws.h"
#endif
#include "bt_task_msg.h"
#include "time_api.h"
#include "driver_pub.h"
#define CFG_CUR_TIME_INFORMER 0
#if CFG_CUR_TIME_INFORMER
@@ -21,7 +21,7 @@
#include "wifi_mac_frame.h"
#include "wifi_msg.h"
#include "wifi_host.h"
#include "time_api.h"
#include "driver_pub.h"
#include "trng_api.h"
#include "flash_api.h"
+10 -29
View File
@@ -1,32 +1,16 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., Ltd. All rights reserved.
* 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
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* http://www.apache.org/licenses/LICENSE-2.0
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* 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.
*/
/**@defgroup los_config System configuration items
@@ -36,10 +20,7 @@
#ifndef _TARGET_CONFIG_H
#define _TARGET_CONFIG_H
//#include "gd32f30x.h"
#include "chip.h"
//#include "gd32f30x_it.h"
#ifdef __cplusplus
#if __cplusplus
-44
View File
@@ -1,44 +0,0 @@
#
# Copyright (c) 2020 Huawei Device Co., Ltd.
# 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.
#
import("//build/lite/config/component/lite_component.gni")
import("//build/lite/ndk/ndk.gni")
import("//third_party/mbedtls/mbedtls.gni")
config("mbedtls_config") {
include_dirs = [ "." ] + MBEDTLS_INLCUDE_DIRS
defines += [
"__unix__",
"MBEDTLS_CONFIG_FILE=<cs_config/config_liteos_m.h>",
]
}
lite_library("mbedtls_static") {
target_type = "static_library"
public_configs = [ ":mbedtls_config" ]
sources = MBEDTLS_SOURCES - [ "$MBEDTLSDIR/library/entropy_poll.c" ] +
[ "library/entropy_poll.c" ] + [ "$MBEDTLSDIR/library/debug.c" ]
}
group("mbedtls") {
public_deps = [ ":mbedtls_static" ]
public_configs = [ ":mbedtls_config" ]
}
ndk_lib("mbedtls_ndk") {
lib_extension = ".a"
deps = [ ":mbedtls" ]
head_files = [ "include" ]
}
File diff suppressed because it is too large Load Diff
-46
View File
@@ -1,46 +0,0 @@
/*
* Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., Ltd. All rights reserved.
* 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(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include <string.h>
#if defined(MBEDTLS_ENTROPY_C)
#include "mbedtls/entropy.h"
#include "mbedtls/entropy_poll.h"
#if defined(MBEDTLS_TEST_NULL_ENTROPY)
#include "stdlib.h"
int mbedtls_null_entropy_poll( void *data,
unsigned char *output, size_t len, size_t *olen )
{
((void) data);
((void) output);
int ret;
uint32_t i;
for (i = 0; i < len; i++) {
output[i] = rand() & 0xFF;
}
*olen = len;
return( 0 );
}
#endif
#endif /* MBEDTLS_ENTROPY_C */