Skip to content

Commit 748a312

Browse files
authored
Merge branch 'apache:master' into master
2 parents be7ce15 + 8f91054 commit 748a312

File tree

10 files changed

+145
-33
lines changed

10 files changed

+145
-33
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ jobs:
9696
echo "apps_ref=$APPS_REF" >> $GITHUB_OUTPUT
9797
9898
- name: Checkout nuttx repo
99-
uses: actions/checkout@v5
99+
uses: actions/checkout@v6
100100
with:
101101
repository: apache/nuttx
102102
ref: ${{ steps.gittargets.outputs.os_ref }}
@@ -106,7 +106,7 @@ jobs:
106106
run: git -C sources/nuttx fetch --tags
107107

108108
- name: Checkout apps repo
109-
uses: actions/checkout@v5
109+
uses: actions/checkout@v6
110110
with:
111111
repository: apache/nuttx-apps
112112
ref: ${{ steps.gittargets.outputs.apps_ref }}
@@ -330,7 +330,7 @@ jobs:
330330
run:
331331
shell: msys2 {0}
332332
steps:
333-
- uses: actions/checkout@v5
333+
- uses: actions/checkout@v6
334334
- uses: msys2/setup-msys2@v2
335335
with:
336336
msystem: MSYS
@@ -404,7 +404,7 @@ jobs:
404404
if: ${{ needs.msvc-Arch.outputs.skip_all_builds != '1' }}
405405
runs-on: windows-latest
406406
steps:
407-
- uses: actions/checkout@v5
407+
- uses: actions/checkout@v6
408408
# Set up Python environment and install kconfiglib
409409
- name: Set up Python and install kconfiglib
410410
uses: actions/setup-python@v6

.github/workflows/check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030

3131
steps:
3232
- name: Checkout nuttx repo
33-
uses: actions/checkout@v5
33+
uses: actions/checkout@v6
3434
with:
3535
repository: apache/nuttx
3636
path: nuttx

.github/workflows/doc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
build-html:
3636
runs-on: ubuntu-latest
3737
steps:
38-
- uses: actions/checkout@v5
38+
- uses: actions/checkout@v6
3939
- uses: actions/setup-python@v6
4040
with:
4141
python-version: '3.8'

.github/workflows/docker_linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
IMAGE_TAG: ghcr.io/${{ github.repository }}/apache-nuttx-ci-linux
4848
steps:
4949
- name: Checkout repository
50-
uses: actions/checkout@v5
50+
uses: actions/checkout@v6
5151

5252
- name: Free Disk Space (Ubuntu)
5353
uses: ./.github/actions/free-disk-space

.github/workflows/labeler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
runs-on: ubuntu-latest
2626
steps:
2727
- name: Checkout repository
28-
uses: actions/checkout@v5
28+
uses: actions/checkout@v6
2929

3030
- name: Assign labels based on paths
3131
uses: actions/labeler@main

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
name: Lint
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v5
20+
- uses: actions/checkout@v6
2121
with:
2222
fetch-depth: 0
2323
- run: mkdir super-linter.report

drivers/timers/arch_alarm.c

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@
3030
#include <nuttx/clock.h>
3131
#include <nuttx/timers/arch_alarm.h>
3232

33+
/****************************************************************************
34+
* Pre-processor Definitions
35+
****************************************************************************/
36+
37+
#define CONFIG_BOARD_LOOPSPER100USEC ((CONFIG_BOARD_LOOPSPERMSEC+5)/10)
38+
#define CONFIG_BOARD_LOOPSPER10USEC ((CONFIG_BOARD_LOOPSPERMSEC+50)/100)
39+
#define CONFIG_BOARD_LOOPSPERUSEC ((CONFIG_BOARD_LOOPSPERMSEC+500)/1000)
40+
3341
/****************************************************************************
3442
* Private Data
3543
****************************************************************************/
@@ -44,6 +52,69 @@ static clock_t g_current_tick;
4452
* Private Functions
4553
****************************************************************************/
4654

55+
static void udelay_coarse(useconds_t microseconds)
56+
{
57+
volatile int i;
58+
59+
/* We'll do this a little at a time because we expect that the
60+
* CONFIG_BOARD_LOOPSPERUSEC is very inaccurate during to truncation in
61+
* the divisions of its calculation. We'll use the largest values that
62+
* we can in order to prevent significant error buildup in the loops.
63+
*/
64+
65+
while (microseconds > 1000)
66+
{
67+
for (i = 0; i < CONFIG_BOARD_LOOPSPERMSEC; i++)
68+
{
69+
}
70+
71+
microseconds -= 1000;
72+
}
73+
74+
while (microseconds > 100)
75+
{
76+
for (i = 0; i < CONFIG_BOARD_LOOPSPER100USEC; i++)
77+
{
78+
}
79+
80+
microseconds -= 100;
81+
}
82+
83+
while (microseconds > 10)
84+
{
85+
for (i = 0; i < CONFIG_BOARD_LOOPSPER10USEC; i++)
86+
{
87+
}
88+
89+
microseconds -= 10;
90+
}
91+
92+
while (microseconds > 0)
93+
{
94+
for (i = 0; i < CONFIG_BOARD_LOOPSPERUSEC; i++)
95+
{
96+
}
97+
98+
microseconds--;
99+
}
100+
}
101+
102+
static void ndelay_accurate(unsigned long nanoseconds)
103+
{
104+
struct timespec now;
105+
struct timespec end;
106+
struct timespec delta;
107+
108+
ONESHOT_CURRENT(g_oneshot_lower, &now);
109+
clock_nsec2time(&delta, nanoseconds);
110+
clock_timespec_add(&now, &delta, &end);
111+
112+
while (clock_timespec_compare(&now, &end) < 0)
113+
{
114+
ONESHOT_CURRENT(g_oneshot_lower, &now);
115+
}
116+
}
117+
47118
static void oneshot_callback(FAR struct oneshot_lowerhalf_s *lower,
48119
FAR void *arg)
49120
{
@@ -74,6 +145,55 @@ static void oneshot_callback(FAR struct oneshot_lowerhalf_s *lower,
74145
* Public Functions
75146
****************************************************************************/
76147

148+
/****************************************************************************
149+
* Name: up_mdelay
150+
*
151+
* Description:
152+
* Delay inline for the requested number of milliseconds.
153+
* WARNING: NOT multi-tasking friendly
154+
*
155+
****************************************************************************/
156+
157+
void weak_function up_mdelay(unsigned int milliseconds)
158+
{
159+
up_udelay(USEC_PER_MSEC * milliseconds);
160+
}
161+
162+
/****************************************************************************
163+
* Name: up_udelay
164+
*
165+
* Description:
166+
* Delay inline for the requested number of microseconds.
167+
* WARNING: NOT multi-tasking friendly
168+
*
169+
****************************************************************************/
170+
171+
void weak_function up_udelay(useconds_t microseconds)
172+
{
173+
up_ndelay(NSEC_PER_USEC * microseconds);
174+
}
175+
176+
/****************************************************************************
177+
* Name: up_ndelay
178+
*
179+
* Description:
180+
* Delay inline for the requested number of nanoseconds.
181+
* WARNING: NOT multi-tasking friendly
182+
*
183+
****************************************************************************/
184+
185+
void weak_function up_ndelay(unsigned long nanoseconds)
186+
{
187+
if (g_oneshot_lower != NULL)
188+
{
189+
ndelay_accurate(nanoseconds);
190+
}
191+
else /* Oneshot timer hasn't been initialized yet */
192+
{
193+
udelay_coarse((nanoseconds + NSEC_PER_USEC - 1) / NSEC_PER_USEC);
194+
}
195+
}
196+
77197
void up_alarm_set_lowerhalf(FAR struct oneshot_lowerhalf_s *lower)
78198
{
79199
#ifdef CONFIG_SCHED_TICKLESS

sched/clock/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ set(SRCS
3535
# include the base delay definition (busy-loop) as a minimum-viable product. We
3636
# don't want the weak references to conflict.
3737

38-
if(NOT CONFIG_TIMER_ARCH)
38+
if(NOT CONFIG_TIMER_ARCH AND NOT CONFIG_ALARM_ARCH)
3939
list(APPEND SRCS delay.c)
4040
endif()
4141

sched/clock/Make.defs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ CSRCS += clock_perf.c clock_realtime2absticks.c
2929
# don't want the weak references to conflict.
3030

3131
ifneq ($(CONFIG_TIMER_ARCH),y)
32-
CSRCS += delay.c
32+
ifneq ($(CONFIG_ALARM_ARCH),y)
33+
CSRCS += delay.c
34+
endif
3335
endif
3436

3537
ifeq ($(CONFIG_CLOCK_TIMEKEEPING),y)

sched/sched/sched_idletask.c

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,28 +60,18 @@ bool sched_idletask(void)
6060
{
6161
FAR struct tcb_s *rtcb = this_task();
6262

63-
/* If called early in the initialization sequence, the tasks lists may not
64-
* have been initialized and, in that case, rtcb may be NULL.
65-
*/
66-
67-
DEBUGASSERT(rtcb != NULL || !OSINIT_TASK_READY());
68-
if (rtcb != NULL)
69-
{
70-
/* The IDLE task TCB is distinguishable by a few things:
71-
*
72-
* (1) It always lies at the end of the task list,
73-
* (2) It always has priority zero, and
74-
* (3) It should have the TCB_FLAG_CPU_LOCKED flag set.
75-
*
76-
* In the non-SMP case, the IDLE task will also have PID=0, but that
77-
* is not a portable test because there are multiple IDLE tasks with
78-
* different PIDs in the SMP configuration.
79-
*/
63+
DEBUGASSERT(rtcb);
8064

81-
return is_idle_task(rtcb);
82-
}
83-
84-
/* We must be on the IDLE thread if we are early in initialization */
65+
/* The IDLE task TCB is distinguishable by a few things:
66+
*
67+
* (1) It always lies at the end of the task list,
68+
* (2) It always has priority zero, and
69+
* (3) It should have the TCB_FLAG_CPU_LOCKED flag set.
70+
*
71+
* In the non-SMP case, the IDLE task will also have PID=0, but that
72+
* is not a portable test because there are multiple IDLE tasks with
73+
* different PIDs in the SMP configuration.
74+
*/
8575

86-
return true;
76+
return is_idle_task(rtcb);
8777
}

0 commit comments

Comments
 (0)