mirror of
https://github.com/firewalkwithm3/Sensor-Watch.git
synced 2024-11-22 11:10:29 +08:00
overdue refactor: compile all watch modules separately
This commit is contained in:
parent
152ba8aec6
commit
39a17c99b9
11
make.mk
11
make.mk
|
@ -71,6 +71,17 @@ SRCS += \
|
|||
$(TOP)/watch-library/main.c \
|
||||
$(TOP)/watch-library/startup_saml22.c \
|
||||
$(TOP)/watch-library/hw/driver_init.c \
|
||||
$(TOP)/watch-library/watch/watch_rtc.c \
|
||||
$(TOP)/watch-library/watch/watch_slcd.c \
|
||||
$(TOP)/watch-library/watch/watch_extint.c \
|
||||
$(TOP)/watch-library/watch/watch_led.c \
|
||||
$(TOP)/watch-library/watch/watch_buzzer.c \
|
||||
$(TOP)/watch-library/watch/watch_adc.c \
|
||||
$(TOP)/watch-library/watch/watch_gpio.c \
|
||||
$(TOP)/watch-library/watch/watch_i2c.c \
|
||||
$(TOP)/watch-library/watch/watch_uart.c \
|
||||
$(TOP)/watch-library/watch/watch_deepsleep.c \
|
||||
$(TOP)/watch-library/watch/watch_private.c \
|
||||
$(TOP)/watch-library/watch/watch.c \
|
||||
$(TOP)/watch-library/hal/src/hal_atomic.c \
|
||||
$(TOP)/watch-library/hal/src/hal_delay.c \
|
||||
|
|
0
watch-library/hal/include/hal_calendar.h
Normal file
0
watch-library/hal/include/hal_calendar.h
Normal file
0
watch-library/hal/src/hal_calendar.c
Normal file
0
watch-library/hal/src/hal_calendar.c
Normal file
|
@ -24,18 +24,6 @@
|
|||
|
||||
#include "watch.h"
|
||||
|
||||
#include "watch_rtc.c"
|
||||
#include "watch_slcd.c"
|
||||
#include "watch_extint.c"
|
||||
#include "watch_led.c"
|
||||
#include "watch_buzzer.c"
|
||||
#include "watch_adc.c"
|
||||
#include "watch_gpio.c"
|
||||
#include "watch_i2c.c"
|
||||
#include "watch_uart.c"
|
||||
#include "watch_deepsleep.c"
|
||||
#include "watch_private.c"
|
||||
|
||||
bool battery_is_low = false;
|
||||
|
||||
// receives interrupts from MCLK, OSC32KCTRL, OSCCTRL, PAC, PM, SUPC and TAL, whatever that is.
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "watch_adc.h"
|
||||
|
||||
void _watch_sync_adc() {
|
||||
while (ADC->SYNCBUSY.reg);
|
||||
}
|
||||
|
|
|
@ -21,8 +21,12 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef _WATCH_ADC_H_INCLUDED
|
||||
#define _WATCH_ADC_H_INCLUDED
|
||||
////< @file watch_adc.h
|
||||
|
||||
#include "watch.h"
|
||||
|
||||
/** @addtogroup adc Analog Input
|
||||
* @brief This section covers functions related to the SAM L22's analog-to-digital converter,
|
||||
* as well as configuring and reading values from the five analog-capable pins on the
|
||||
|
@ -103,3 +107,4 @@ void watch_disable_analog_input(const uint8_t pin);
|
|||
void watch_disable_adc();
|
||||
|
||||
/// @}
|
||||
#endif
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef _WATCH_APP_H_INCLUDED
|
||||
#define _WATCH_APP_H_INCLUDED
|
||||
////< @file watch_app.h
|
||||
|
||||
/** @addtogroup app Application Framework
|
||||
|
@ -103,3 +105,4 @@ void app_prepare_for_sleep();
|
|||
void app_wake_from_sleep();
|
||||
|
||||
/// @}
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "watch_buzzer.h"
|
||||
|
||||
inline void watch_enable_buzzer() {
|
||||
if (!hri_tcc_get_CTRLA_reg(TCC0, TCC_CTRLA_ENABLE)) {
|
||||
_watch_enable_tcc();
|
||||
|
|
|
@ -21,8 +21,12 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef _WATCH_BUZZER_H_INCLUDED
|
||||
#define _WATCH_BUZZER_H_INCLUDED
|
||||
////< @file watch_buzzer.h
|
||||
|
||||
#include "watch.h"
|
||||
|
||||
/** @addtogroup buzzer Buzzer
|
||||
* @brief This section covers functions related to the piezo buzzer embedded in the F-91W's back plate.
|
||||
*/
|
||||
|
@ -157,3 +161,4 @@ void watch_buzzer_play_note(BuzzerNote note, uint16_t duration_ms);
|
|||
extern const uint16_t NotePeriods[108];
|
||||
|
||||
/// @}
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "watch_extint.h"
|
||||
|
||||
// this warning only appears when you `make BOARD=OSO-SWAT-A1-02`. it's annoying,
|
||||
// but i'd rather have it warn us at build-time than fail silently at run-time.
|
||||
// besides, no one but me really has any of these boards anyway.
|
||||
|
|
|
@ -21,8 +21,12 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef _WATCH_DEEPSLEEP_H_INCLUDED
|
||||
#define _WATCH_DEEPSLEEP_H_INCLUDED
|
||||
////< @file watch_deepsleep.h
|
||||
|
||||
#include "watch.h"
|
||||
|
||||
// These are declared in watch_rtc.c.
|
||||
extern ext_irq_cb_t btn_alarm_callback;
|
||||
extern ext_irq_cb_t a2_callback;
|
||||
|
@ -115,3 +119,4 @@ void watch_enter_shallow_sleep(char *message);
|
|||
*/
|
||||
void watch_enter_deep_sleep();
|
||||
/// @}
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "watch_extint.h"
|
||||
|
||||
void watch_enable_external_interrupts() {
|
||||
// Configure EIC to use GCLK3 (the 32.768 kHz crystal)
|
||||
hri_gclk_write_PCHCTRL_reg(GCLK, EIC_GCLK_ID, GCLK_PCHCTRL_GEN_GCLK3_Val | (1 << GCLK_PCHCTRL_CHEN_Pos));
|
||||
|
|
|
@ -21,8 +21,11 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef _WATCH_EXTINT_H_INCLUDED
|
||||
#define _WATCH_EXTINT_H_INCLUDED
|
||||
////< @file watch_extint.h
|
||||
|
||||
#include "watch.h"
|
||||
#include "hal_ext_irq.h"
|
||||
|
||||
/** @addtogroup buttons Buttons & External Interrupts
|
||||
|
@ -78,3 +81,4 @@ void watch_register_button_callback(const uint8_t pin, ext_irq_cb_t callback);
|
|||
__attribute__((deprecated("Use watch_enable_external_interrupts instead")))
|
||||
void watch_enable_buttons();
|
||||
/// @}
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "watch_gpio.h"
|
||||
|
||||
void watch_enable_digital_input(const uint8_t pin) {
|
||||
gpio_set_pin_direction(pin, GPIO_DIRECTION_IN);
|
||||
gpio_set_pin_function(pin, GPIO_PIN_FUNCTION_OFF);
|
||||
|
|
|
@ -21,8 +21,12 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef _WATCH_GPIO_H_INCLUDED
|
||||
#define _WATCH_GPIO_H_INCLUDED
|
||||
////< @file watch_gpio.h
|
||||
|
||||
#include "watch.h"
|
||||
|
||||
/** @addtogroup gpio Digital Input and Output
|
||||
* @brief This section covers functions related to general-purpose input and output signals.
|
||||
*/
|
||||
|
@ -69,3 +73,4 @@ void watch_disable_digital_output(const uint8_t pin);
|
|||
*/
|
||||
void watch_set_pin_level(const uint8_t pin, const bool level);
|
||||
/// @}
|
||||
#endif
|
||||
|
|
|
@ -22,7 +22,9 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
struct io_descriptor *I2C_0_io;
|
||||
#include "watch_i2c.h"
|
||||
|
||||
struct io_descriptor *I2C_0_io;
|
||||
|
||||
void watch_enable_i2c() {
|
||||
I2C_0_init();
|
||||
|
|
|
@ -21,8 +21,12 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef _WATCH_I2C_H_INCLUDED
|
||||
#define _WATCH_I2C_H_INCLUDED
|
||||
////< @file watch_i2c.h
|
||||
|
||||
#include "watch.h"
|
||||
|
||||
/** @addtogroup i2c I2C Controller Driver
|
||||
* @brief This section covers functions related to the SAM L22's built-I2C driver, including
|
||||
* configuring the I2C bus, putting values directly on the bus and reading data from
|
||||
|
@ -99,3 +103,4 @@ uint32_t watch_i2c_read24(int16_t addr, uint8_t reg);
|
|||
*/
|
||||
uint32_t watch_i2c_read32(int16_t addr, uint8_t reg);
|
||||
/// @}
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "watch_led.h"
|
||||
|
||||
void watch_enable_leds() {
|
||||
if (!hri_tcc_get_CTRLA_reg(TCC0, TCC_CTRLA_ENABLE)) {
|
||||
_watch_enable_tcc();
|
||||
|
|
|
@ -21,8 +21,12 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef _WATCH_LED_H_INCLUDED
|
||||
#define _WATCH_LED_H_INCLUDED
|
||||
////< @file watch_led.h
|
||||
|
||||
#include "watch.h"
|
||||
|
||||
/** @addtogroup led LED Control
|
||||
* @brief This section covers functions related to the bi-color red/green LED mounted behind the LCD.
|
||||
* @details The SAM L22 is an exceedingly power efficient chip, whereas the LED's are relatively power-
|
||||
|
@ -86,3 +90,4 @@ void watch_enable_led(bool unused);
|
|||
__attribute__((deprecated("Use watch_disable_leds instead")))
|
||||
void watch_disable_led(bool unused);
|
||||
/// @}
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "watch_private.h"
|
||||
#include "tusb.h"
|
||||
|
||||
void _watch_init() {
|
||||
|
|
|
@ -21,10 +21,17 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef _WATCH_PRIVATE_H_INCLUDED
|
||||
#define _WATCH_PRIVATE_H_INCLUDED
|
||||
|
||||
#include "watch.h"
|
||||
|
||||
/// Called by main.c while setting up the app. You should not call this from your app.
|
||||
void _watch_init();
|
||||
|
||||
/// Initializes the real-time clock peripheral.
|
||||
void _watch_rtc_init();
|
||||
|
||||
/// Called by buzzer and LED setup functions. You should not call this from your app.
|
||||
void _watch_enable_tcc();
|
||||
|
||||
|
@ -33,3 +40,4 @@ void _watch_disable_tcc();
|
|||
|
||||
/// Called by main.c if plugged in to USB. You should not call this from your app.
|
||||
void _watch_enable_usb();
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "watch_rtc.h"
|
||||
|
||||
ext_irq_cb_t tick_callback;
|
||||
ext_irq_cb_t alarm_callback;
|
||||
ext_irq_cb_t btn_alarm_callback;
|
||||
|
|
|
@ -21,8 +21,11 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef _WATCH_RTC_H_INCLUDED
|
||||
#define _WATCH_RTC_H_INCLUDED
|
||||
////< @file watch_rtc.h
|
||||
|
||||
#include "watch.h"
|
||||
#include "hpl_calendar.h"
|
||||
|
||||
/** @addtogroup rtc Real-Time Clock
|
||||
|
@ -122,3 +125,4 @@ __attribute__((deprecated("Use the watch_rtc_get_date_time function instead")))
|
|||
void watch_get_date_time(struct calendar_date_time *date_time);
|
||||
|
||||
/// @}
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "watch_slcd.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Segmented Display
|
||||
|
||||
|
|
|
@ -21,8 +21,12 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef _WATCH_SLCD_H_INCLUDED
|
||||
#define _WATCH_SLCD_H_INCLUDED
|
||||
////< @file watch_slcd.h
|
||||
|
||||
#include "watch.h"
|
||||
|
||||
/** @addtogroup slcd Segment LCD Display
|
||||
* @brief This section covers functions related to the Segment LCD display driver, which is responsible
|
||||
* for displaying strings of characters and indicators on the main watch display.
|
||||
|
@ -100,3 +104,4 @@ void watch_clear_indicator(WatchIndicatorSegment indicator);
|
|||
void watch_clear_all_indicators();
|
||||
|
||||
/// @}
|
||||
#endif
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "watch_uart.h"
|
||||
#include "peripheral_clk_config.h"
|
||||
|
||||
void watch_enable_debug_uart(uint32_t baud) {
|
||||
|
|
|
@ -21,8 +21,12 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#ifndef _WATCH_UART_H_INCLUDED
|
||||
#define _WATCH_UART_H_INCLUDED
|
||||
////< @file watch_uart.h
|
||||
|
||||
#include "watch.h"
|
||||
|
||||
/** @addtogroup debug Debug UART
|
||||
* @brief This section covers functions related to the debug UART, available on
|
||||
* pin D1 of the 9-pin connector.
|
||||
|
@ -51,3 +55,4 @@ void watch_debug_putc(char c);
|
|||
__attribute__((deprecated("Use printf to log debug messages over USB.")))
|
||||
void watch_debug_puts(char *s);
|
||||
/// @}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue