Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Projet_Pico_ordi_B6
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Man hing Ling
Projet_Pico_ordi_B6
Commits
69108e86
Commit
69108e86
authored
1 year ago
by
dylanling2
Browse files
Options
Downloads
Patches
Plain Diff
debut ordonnanceur
parent
d18e10fc
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
PicoShield/CarteMerePicoB6/ordonnanceur.c
+108
-0
108 additions, 0 deletions
PicoShield/CarteMerePicoB6/ordonnanceur.c
with
108 additions
and
0 deletions
PicoShield/CarteMerePicoB6/ordonnanceur.c
0 → 100644
+
108
−
0
View file @
69108e86
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
#include
<avr/io.h>
// for the input/output register
#include
<util/delay.h>
// for the _delay_ms
#include
<avr/interrupt.h>
struct
process
{
int
*
stackPointer
;
void
(
*
ptask
)();
//pointer fonction
char
*
state
;
};
void
init_timer
()
{
TCCR1B
|=
_BV
(
WGM12
);
// CTC mode with value in OCR1A
TCCR1B
|=
_BV
(
CS12
);
// CS12 = 1; CS11 = 0; CS10 =1 => CLK/1024 prescaler
TCCR1B
|=
_BV
(
CS10
);
OCR1A
=
NB_TICK
;
TIMSK1
|=
_BV
(
OCIE1A
);
}
struct
process
process_tab
[
2
];
process_tab
[
0
].
ptask
=
&
task_led_green
;
process_tab
[
1
].
ptask
=
&
task_led_red
;
void
scheduler
()
{
}
ISR
(
TIMER1_COMPA_vect
,
ISR_NAKED
)
{
/* Sauvegarde du contexte de la tâche interrompue */
//PC est automatiquement mis sur la pile
//on met les registres d'etat sur la pile
#define portSAVE_CONTEXT() \
asm volatile ( \
"push r0 \n\t" \
"in r0, __SREG__
\n\t
"
\
//push SREG
"cli
\n\t
"
\
"push r0
\n\t
"
\
"push r1
\n\t
"
\
"clr r1
\n\t
"
\
"push r2
\n\t
"
\
"push r3
\n\t
"
\
"push r4
\n\t
"
\
"push r5
\n\t
"
\
"push r6
\n\t
"
\
"push r7
\n\t
"
\
"push r8
\n\t
"
\
"push r9
\n\t
"
\
"push r10
\n\t
"
\
"push r11
\n\t
"
\
"push r12
\n\t
"
\
"push r13
\n\t
"
\
"push r14
\n\t
"
\
"push r15
\n\t
"
\
"push r16
\n\t
"
\
"push r17
\n\t
"
\
"push r18
\n\t
"
\
"push r19
\n\t
"
\
"push r20
\n\t
"
\
"push r21
\n\t
"
\
"push r22
\n\t
"
\
"push r23
\n\t
"
\
"push r24
\n\t
"
\
"push r25
\n\t
"
\
"push r26
\n\t
"
\
"push r27
\n\t
"
\
"push r28
\n\t
"
\
"push r29
\n\t
"
\
"push r30
\n\t
"
\
"push r31
\n\t
"
\
);
current_process
.
stackPointer
=
SP
;
/* Appel à l'ordonnanceur */
scheduler
();
/* Récupération du contexte de la tâche ré-activée */
...
asm
volatile
(
"reti"
);
}
void
task_led_red
(
void
)
{
}
void
task_led_green
(
void
)
{
}
int
main
()
{
process_tab
[
0
].
ptask
=
&
task_led_green
;
process_tab
[
1
].
ptask
=
&
task_led_red
;
process_tab
[
0
].
state
=
"sleep"
;
process_tab
[
1
].
state
=
"sleep"
;
init_timer
();
while
(
1
)
{
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment