-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ajout de la RTC #26
Open
rdmsr
wants to merge
4
commits into
devse-org:master
Choose a base branch
from
rdmsr:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Ajout de la RTC #26
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<center> | ||
<b>Attention!</b><br>Cet article est en cours de rédaction. | ||
</center> | ||
|
||
# Introduction | ||
|
||
RTC ou Real-Time Clock, est une puce qui mesure le passage du temps. | ||
Elle peut être utilisée pour avoir la date et heure précise. (voir ACPI pour le siècle) | ||
|
||
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/6/60/Dallas-Semiconductor-DS1287-Real-Time-IC.jpg/1920px-Dallas-Semiconductor-DS1287-Real-Time-IC.jpg" width="400"> | ||
|
||
|
||
# Lire le temps | ||
Il est possible de lire depuis la RTC en utilisant les fonctions suivantes: | ||
```c | ||
|
||
enum | ||
{ | ||
CMOS_ADDRESS = 0x70, | ||
CMOS_DATA = 0x71, | ||
STATUS_REGISTER_A = 0x0A | ||
}; | ||
|
||
/* Vérifier si la RTC est en train de se mettre à jour */ | ||
int rtc_is_updating() | ||
{ | ||
outb(CMOS_ADDRESS, STATUS_REGISTER_A); | ||
return inb(CMOS_DATA) & 0x80; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe add a signification of the last bit ? |
||
} | ||
|
||
unsigned char rtc_read(int reg) | ||
{ | ||
while (rtc_is_updating()); /* Attendre que l'update finisse */ | ||
outb(CMOS_ADDRESS, reg); | ||
|
||
return inb(CMOS_DATA); | ||
} | ||
``` | ||
Voici la table des éléments à lire depuis la RTC et leur registre CMOS | ||
| Élement de temps | Registre | ||
|-------------|---------------| | ||
| Secondes | 0x0 | | ||
| Minutes | 0x02 | | ||
| Heures | 0x04 | | ||
| Jour de la semaine | 0x06 | | ||
| Jour | 0x07 | | ||
| Année | 0x09 | | ||
|
||
**Note:** les valeurs retournées sont en BCD et non pas en décimal. | ||
# Exemples | ||
Voici un exemple d'une lecture des secondes | ||
|
||
```c | ||
unsigned char rtc_get_seconds() | ||
{ | ||
unsigned char seconds = rtc_read(0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. peut être utilier une macro RTC_SECOND_REGISTER à la place de 0 |
||
unsigned char second = (seconds & 0x0F) + ((seconds / 16) * 10); /* Convertir au décimal */ | ||
return second; | ||
} | ||
``` | ||
|
||
# Ressources | ||
- [Wikipedia](https://en.wikipedia.org/wiki/Real-time_clock) | ||
- [OSDev.org - CMOS](https://wiki.osdev.org/CMOS) | ||
- [OSDev.org - RTC](https://wiki.osdev.org/RTC) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the documentation, put a markdown table instead of a C code enum, it's better for reading
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and add other register, like STATUS_REGISTER_B, week, day, hour, ... in the table (maybe ?)