This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce per-target files (aka "hardware abstraction layer")
- Loading branch information
Showing
8 changed files
with
169 additions
and
108 deletions.
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
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
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
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,47 @@ | ||
#ifndef HWCONFIG_H | ||
#define HWCONFIG_H | ||
|
||
/* | ||
* the main model, based either on stc15f204ea or stc15w404as MCU | ||
*/ | ||
|
||
// alias for relay and buzzer outputs, using relay to drive led for indication of main loop status | ||
#define RELAY P1_4 | ||
#define BUZZER P1_5 | ||
#define BUZZER_ON BUZZER = 0 | ||
#define BUZZER_OFF BUZZER = 1 | ||
|
||
// 7-seg led port setup | ||
|
||
// which port the segments are connected to | ||
#define LED_SEGMENT_PORT P2 | ||
// which port controls the digits | ||
#define LED_DIGITS_PORT P3 | ||
|
||
// offset where the digits start on LED_DIGITS_PORT | ||
#define LED_DIGITS_PORT_BASE 2 | ||
|
||
// setup macro mask to turn off digits | ||
#define LED_DIGITS_OFF() ( LED_DIGITS_PORT |= (0b1111 << LED_DIGITS_PORT_BASE)) | ||
// setup macro to turn on single digit | ||
#define LED_DIGIT_ON(digit) (LED_DIGITS_PORT &= ~((1<<LED_DIGITS_PORT_BASE) << digit)) | ||
|
||
// adc channels for sensors, P1_n | ||
#define ADC_LIGHT 6 | ||
#define ADC_TEMP 7 | ||
|
||
// button switch aliases | ||
#define SW1 P3_1 | ||
#define SW2 P3_0 | ||
#define NUM_SW 2 | ||
|
||
// ds1302 pins | ||
#define DS_CE P1_0 | ||
#define DS_IO P1_1 | ||
#define DS_SCLK P1_2 | ||
// needed for asm optimizations | ||
#define _DS_IO _P1_1 | ||
#define _DS_SCLK _P1_2 | ||
|
||
#endif // #ifndef HWCONFIG_H | ||
|
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,48 @@ | ||
#ifndef HWCONFIG_H | ||
#define HWCONFIG_H | ||
|
||
/* | ||
* The variant based on MCU stc15f204 and described here: | ||
* https://github.com/zerog2k/stc_diyclock/issues/20 | ||
*/ | ||
|
||
// alias for relay and buzzer outputs, using relay to drive led for indication of main loop status | ||
#define RELAY | ||
#define BUZZER P3_3 | ||
#define BUZZER_ON BUZZER = 0 | ||
#define BUZZER_OFF BUZZER = 1 | ||
|
||
// 7-seg led port setup | ||
|
||
// which port the segments are connected to | ||
#define LED_SEGMENT_PORT P2 | ||
// which port controls the digits | ||
#define LED_DIGITS_PORT P3 | ||
|
||
// offset where the digits start on LED_DIGITS_PORT | ||
#define LED_DIGITS_PORT_BASE 4 | ||
|
||
// setup macro mask to turn off digits | ||
#define LED_DIGITS_OFF() ( LED_DIGITS_PORT |= (0b1111 << LED_DIGITS_PORT_BASE)) | ||
// setup macro to turn on single digit | ||
#define LED_DIGIT_ON(digit) (LED_DIGITS_PORT &= ~((1<<LED_DIGITS_PORT_BASE) << digit)) | ||
|
||
// adc channels for sensors, P1_n | ||
#define ADC_LIGHT 3 | ||
#define ADC_TEMP 6 | ||
|
||
// button switch aliases | ||
#define SW1 P3_1 | ||
#define SW2 P3_0 | ||
#define NUM_SW 2 | ||
|
||
// ds1302 pins | ||
#define DS_CE P0_0 | ||
#define DS_IO P0_1 | ||
#define DS_SCLK P3_2 | ||
// needed for asm optimizations | ||
#define _DS_IO _P0_1 | ||
#define _DS_SCLK _P3_2 | ||
|
||
#endif // #ifndef HWCONFIG_H | ||
|
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,48 @@ | ||
#ifndef HWCONFIG_H | ||
#define HWCONFIG_H | ||
|
||
/* | ||
* hardware with stc15w408as and voice chips | ||
*/ | ||
|
||
#define LED P1_5 | ||
// no buzzer ? | ||
#define BUZZER_ON | ||
#define BUZZER_OFF | ||
|
||
// 7-seg led port setup | ||
|
||
// which port the segments are connected to | ||
#define LED_SEGMENT_PORT P2 | ||
// which port controls the digits | ||
#define LED_DIGITS_PORT P3 | ||
|
||
// offset where the digits start on LED_DIGITS_PORT | ||
#define LED_DIGITS_PORT_BASE 2 | ||
|
||
// setup macro mask to turn off digits | ||
#define LED_DIGITS_OFF() ( LED_DIGITS_PORT |= (0b1111 << LED_DIGITS_PORT_BASE)) | ||
// setup macro to turn on single digit | ||
#define LED_DIGIT_ON(digit) (LED_DIGITS_PORT &= ~((1<<LED_DIGITS_PORT_BASE) << digit)) | ||
|
||
// adc channels for sensors, P1_n | ||
#define ADC_LIGHT 6 | ||
#define ADC_TEMP 7 | ||
|
||
// button switch aliases | ||
// the stc15w408as has a third one | ||
#define SW1 P3_1 | ||
#define SW2 P3_0 | ||
#define SW3 P1_4 | ||
#define NUM_SW 3 | ||
|
||
// ds1302 pins | ||
#define DS_CE P1_0 | ||
#define DS_IO P1_1 | ||
#define DS_SCLK P1_2 | ||
// needed for asm optimizations | ||
#define _DS_IO _P1_1 | ||
#define _DS_SCLK _P1_2 | ||
|
||
#endif // #ifndef HWCONFIG_H | ||
|
This file was deleted.
Oops, something went wrong.
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