Skip to content

Commit 702a35b

Browse files
committed
Update libraries projects tools ReadMe
1 parent a9348ba commit 702a35b

File tree

14,013 files changed

+2937965
-1268802
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

14,013 files changed

+2937965
-1268802
lines changed

.github/workflows/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
- {RTT_BSP: "Edgi-Talk_Blink_Led/Edgi_Talk_M33_Blink_LED"}
5858
- {RTT_BSP: "Edgi-Talk_Blink_Led/Edgi_Talk_M55_Blink_LED"}
5959
- {RTT_BSP: "Edgi-Talk_CoreMark/Edgi_Talk_M55_CoreMark"}
60-
- {RTT_BSP: "Edgi-Talk_emUSB-device_CDC_Echo/Edgi_Talk_M33_emUSB-device_CDC_Echo"}
60+
- {RTT_BSP: "Edgi-Talk_CDC_Echo/Edgi_Talk_M33_CDC_Echo"}
6161
- {RTT_BSP: "Edgi-Talk_HyperRam/Edgi_Talk_M33_HyperRam"}
6262
- {RTT_BSP: "Edgi-Talk_Key_Irq/Edgi_Talk_M33_Key_Irq"}
6363
- {RTT_BSP: "Edgi-Talk_LSM6DS3/Edgi_Talk_M33_LSM6DS3"}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ $ sdk-bsp-psoc_e84-edgi-talk
2929
│ ├── Edgi-Talk_Audio
3030
│ ├── Edgi-Talk_Blink_Led
3131
│ ├── Edgi-Talk_CoreMark
32-
│ ├── Edgi-Talk_emUSB_device_CDC_Echo
32+
│ ├── Edgi-Talk_CDC_Echo
3333
│ ├── Edgi-Talk_HyperRam
3434
│ ├── Edgi-Talk_Key_Irq
3535
│ ├── Edgi-Talk_LSM6DS3
@@ -110,4 +110,4 @@ The system boot sequence is as follows:
110110
```
111111
RT-Thread Settings --> Hardware --> select SOC Multi Core Mode --> Enable CM55 Core
112112
```
113-
113+
![Enable M55](docs/figures/config.png)

README_zh.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ $ sdk-bsp-psoc_e84-edgi-talk
2929
│ ├── Edgi-Talk_Audio
3030
│ ├── Edgi-Talk_Blink_Led
3131
│ ├── Edgi-Talk_CoreMark
32-
│ ├── Edgi-Talk_emUSB_device_CDC_Echo
32+
│ ├── Edgi-Talk_CDC_Echo
3333
│ ├── Edgi-Talk_HyperRam
3434
│ ├── Edgi-Talk_Key_Irq
3535
│ ├── Edgi-Talk_LSM6DS3
@@ -109,5 +109,6 @@ $ sdk-bsp-psoc_e84-edgi-talk
109109
```
110110
RT-Thread Settings --> 硬件 --> select SOC Multi Core Mode --> Enable CM55 Core
111111
```
112+
![开启M55](docs/figures/config.png)
112113

113114

docs/figures/config.png

65.2 KB
Loading

libraries/HAL_Drivers/drv_i2c.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
#define I2C0_CONFIG \
1919
{ \
2020
.name = "i2c0", \
21-
.base = CYBSP_I2C_CONTROLLER_0_HW, \
22-
.cy_stc_scb_i2c_config = &CYBSP_I2C_CONTROLLER_0_config, \
23-
.mtb_hal_i2c_configurator = &CYBSP_I2C_CONTROLLER_0_hal_config, \
21+
.base = CYBSP_I2C_CONTROLLER_HW, \
22+
.cy_stc_scb_i2c_config = &CYBSP_I2C_CONTROLLER_config, \
23+
.mtb_hal_i2c_configurator = &CYBSP_I2C_CONTROLLER_hal_config, \
2424
}
2525
#endif /* I2C0_CONFIG */
2626

libraries/HAL_Drivers/drv_rtc.c

Lines changed: 65 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -13,124 +13,112 @@
1313

1414
#ifdef BSP_USING_RTC
1515

16-
//#define DRV_DEBUG
17-
#define LOG_TAG "drv.rtc"
16+
#define LOG_TAG "drv.rtc"
1817
#include <drv_log.h>
1918

2019
static rt_rtc_dev_t ifx32_rtc_dev;
2120

2221
static int get_day_of_week(int day, int month, int year)
2322
{
24-
int ret;
25-
int k = 0;
26-
int j = 0;
27-
28-
if (month < CY_RTC_MARCH)
23+
if (month < 3)
2924
{
30-
month += CY_RTC_MONTHS_PER_YEAR;
31-
year--;
25+
month += 12;
26+
year -= 1;
3227
}
3328

34-
k = (year % 100);
35-
j = (year / 100);
36-
ret = (day + (13 * (month + 1) / 5) + k + (k / 4) + (j / 4) + (5 * j)) % 7;
37-
ret = ((ret + 6) % 7);
29+
int k = year % 100;
30+
int j = year / 100;
31+
32+
int ret = (day + (13 * (month + 1)) / 5 + k + (k / 4) + (j / 4) + (5 * j)) % 7;
33+
ret = (ret + 6) % 7;
3834

39-
return ret;
35+
return ret + 1;
4036
}
4137

42-
static rt_err_t set_rtc_time_stamp(time_t time_stamp)
38+
static rt_err_t set_rtc_time_stamp(time_t timestamp)
4339
{
4440
struct tm tm = {0};
45-
cy_stc_rtc_config_t new_time = {0};
46-
47-
gmtime_r(&time_stamp, &tm);
41+
gmtime_r(&timestamp, &tm);
4842

49-
if (tm.tm_year < 100)
43+
int full_year = tm.tm_year + 1900;
44+
if (full_year < 2000 || full_year > 2099)
5045
{
46+
LOG_E("RTC year out of range: %d", full_year);
5147
return -RT_ERROR;
5248
}
5349

54-
new_time.sec = tm.tm_sec;
55-
new_time.min = tm.tm_min;
56-
new_time.hour = tm.tm_hour;
57-
new_time.date = tm.tm_mday;
58-
new_time.month = tm.tm_mon;
59-
new_time.year = tm.tm_year - 100;
60-
new_time.dayOfWeek = get_day_of_week(tm.tm_mday, tm.tm_mon, tm.tm_year);
50+
cy_stc_rtc_config_t new_time;
51+
memset(&new_time, 0, sizeof(new_time));
6152

62-
Cy_RTC_SetDateAndTime(&new_time);
53+
new_time.sec = tm.tm_sec;
54+
new_time.min = tm.tm_min;
55+
new_time.hour = tm.tm_hour;
56+
new_time.date = tm.tm_mday;
57+
new_time.month = tm.tm_mon + 1;
58+
new_time.year = full_year - 2000;
59+
new_time.dayOfWeek = get_day_of_week(tm.tm_mday, tm.tm_mon + 1, full_year);
6360

64-
LOG_D("set rtc time.");
61+
new_time.hrFormat = CY_RTC_24_HOURS;
62+
new_time.amPm = CY_RTC_AM;
6563

66-
return RT_EOK;
64+
LOG_D("SET RTC %04d-%02d-%02d %02d:%02d:%02d (W=%d)",
65+
full_year, new_time.month, new_time.date,
66+
new_time.hour, new_time.min, new_time.sec,
67+
new_time.dayOfWeek);
68+
69+
cy_en_rtc_status_t status = Cy_RTC_SetDateAndTime(&new_time);
70+
return (status == CY_RTC_SUCCESS) ? RT_EOK : -RT_ERROR;
6771
}
6872

6973
static rt_err_t ifx_rtc_get_timeval(struct timeval *tv)
7074
{
71-
struct tm tm_new = {0};
72-
cy_stc_rtc_config_t date_time = {0};
73-
74-
Cy_RTC_GetDateAndTime(&date_time);
75+
cy_stc_rtc_config_t dt;
76+
Cy_RTC_GetDateAndTime(&dt);
7577

76-
tm_new.tm_sec = date_time.sec;
77-
tm_new.tm_min = date_time.min;
78-
tm_new.tm_hour = date_time.hour;
79-
tm_new.tm_mday = date_time.date;
80-
tm_new.tm_mon = date_time.month;
81-
tm_new.tm_year = date_time.year + 100;
78+
struct tm tm_new = {0};
79+
tm_new.tm_sec = dt.sec;
80+
tm_new.tm_min = dt.min;
81+
tm_new.tm_hour = dt.hour;
82+
tm_new.tm_mday = dt.date;
83+
tm_new.tm_mon = dt.month - 1;
84+
tm_new.tm_year = dt.year + 100;
8285

8386
tv->tv_sec = timegm(&tm_new);
87+
tv->tv_usec = 0;
8488

85-
return RT_EOK;
86-
}
87-
88-
static rt_err_t _rtc_init(void)
89-
{
90-
91-
/* Variable used to store return status of RTC API */
92-
cy_en_rtc_status_t rtc_status;
93-
uint32_t rtc_access_retry = 500;
94-
95-
/* RTC block doesn't allow to access, when synchronizing the user registers
96-
* and the internal actual RTC registers. It will return RTC_BUSY value, if
97-
* it is not available to update the configuration values. Needs to retry,
98-
* if it doesn't return CY_RTC_SUCCESS. */
99-
100-
do
101-
{
102-
rtc_status = Cy_RTC_Init(&CYBSP_RTC_config);
103-
rtc_access_retry--;
104-
rt_thread_mdelay(5);
105-
}
106-
while ((rtc_status != CY_RTC_SUCCESS) && (rtc_access_retry != 0));
89+
LOG_D("GET RTC %04d-%02d-%02d %02d:%02d:%02d",
90+
tm_new.tm_year + 1900, tm_new.tm_mon + 1, tm_new.tm_mday,
91+
tm_new.tm_hour, tm_new.tm_min, tm_new.tm_sec);
10792

108-
return rtc_status;
93+
return RT_EOK;
10994
}
11095

11196
static rt_err_t _rtc_get_secs(time_t *sec)
11297
{
11398
struct timeval tv;
114-
11599
ifx_rtc_get_timeval(&tv);
116-
*(time_t *)sec = tv.tv_sec;
117-
LOG_D("RTC: get rtc_time %d", *sec);
118-
100+
*sec = tv.tv_sec;
119101
return RT_EOK;
120102
}
121103

122104
static rt_err_t _rtc_set_secs(time_t *sec)
123105
{
124-
rt_err_t result = RT_EOK;
106+
return set_rtc_time_stamp(*sec);
107+
}
108+
109+
static rt_err_t _rtc_init(void)
110+
{
111+
cy_en_rtc_status_t status;
112+
uint32_t retry = 500;
125113

126-
if (set_rtc_time_stamp(*sec))
114+
do
127115
{
128-
result = -RT_ERROR;
116+
status = Cy_RTC_Init(&CYBSP_RTC_config);
117+
rt_thread_mdelay(5);
129118
}
119+
while (status != CY_RTC_SUCCESS && retry--);
130120

131-
LOG_D("RTC: set rtc_time %d", *sec);
132-
133-
return result;
121+
return (status == CY_RTC_SUCCESS) ? RT_EOK : -RT_ERROR;
134122
}
135123

136124
static const struct rt_rtc_ops _rtc_ops =
@@ -144,29 +132,19 @@ static const struct rt_rtc_ops _rtc_ops =
144132
RT_NULL,
145133
};
146134

147-
/**
148-
* @brief RTC initialization function.
149-
*
150-
* @return RT_EOK indicates successful initialization, other value indicates failed;
151-
*/
152135
static int rt_hw_rtc_init(void)
153136
{
154-
rt_err_t result = RT_EOK;
155-
156137
ifx32_rtc_dev.ops = &_rtc_ops;
157138

158139
if (rt_hw_rtc_register(&ifx32_rtc_dev, "rtc", RT_DEVICE_FLAG_RDWR, RT_NULL) != RT_EOK)
159140
{
160-
LOG_E("rtc init failed");
161-
result = -RT_ERROR;
162-
}
163-
else
164-
{
165-
LOG_D("rtc init success");
141+
LOG_E("RTC register failed");
142+
return -RT_ERROR;
166143
}
167144

168-
return result;
145+
LOG_D("RTC init success");
146+
return RT_EOK;
169147
}
170-
171148
INIT_DEVICE_EXPORT(rt_hw_rtc_init);
149+
172150
#endif

0 commit comments

Comments
 (0)