aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/src/hal_wdg.c
blob: 544410db58821c11ff9b8403289d4b47e278a307 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
    ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
*/

/**
 * @file    hal_wdg.c
 * @brief   WDG Driver code.
 *
 * @addtogroup WDG
 * @{
 */

#include "hal.h"

#if (HAL_USE_WDG == TRUE) || defined(__DOXYGEN__)

/*===========================================================================*/
/* Driver local definitions.                                                 */
/*===========================================================================*/

/*===========================================================================*/
/* Driver exported variables.                                                */
/*===========================================================================*/

/*===========================================================================*/
/* Driver local variables.                                                   */
/*===========================================================================*/

/*===========================================================================*/
/* Driver local functions.                                                   */
/*===========================================================================*/

/*===========================================================================*/
/* Driver exported functions.                                                */
/*===========================================================================*/

/**
 * @brief   WDG Driver initialization.
 * @note    This function is implicitly invoked by @p halInit(), there is
 *          no need to explicitly initialize the driver.
 *
 * @init
 */
void wdgInit(void) {
    
  wdg_lld_init();
}

/**
 * @brief   Configures and activates the WDG peripheral.
 *
 * @param[in] wdgp      pointer to the @p WDGDriver object
 * @param[in] config    pointer to the @p WDGConfig object
 *
 * @api
 */
void wdgStart(WDGDriver *wdgp, const WDGConfig *config) {

  osalDbgCheck((wdgp != NULL) && (config != NULL));

  osalSysLock();
  osalDbgAssert((wdgp->state == WDG_STOP) || (wdgp->state == WDG_READY),
                "invalid state");
  wdgp->config = config;
  wdg_lld_start(wdgp);
  wdgp->state = WDG_READY;
  osalSysUnlock();
}

/**
 * @brief   Deactivates the WDG peripheral.
 *
 * @param[in] wdgp      pointer to the @p WDGDriver object
 *
 * @api
 */
void wdgStop(WDGDriver *wdgp) {

  osalDbgCheck(wdgp != NULL);

  osalSysLock();

  osalDbgAssert((wdgp->state == WDG_STOP) || (wdgp->state == WDG_READY),
                "invalid state");

  wdg_lld_stop(wdgp);
  wdgp->config = NULL;
  wdgp->state  = WDG_STOP;

  osalSysUnlock();
}

/**
 * @brief   Resets WDG's counter.
 *
 * @param[in] wdgp      pointer to the @p WDGDriver object
 *
 * @api
 */
void wdgReset(WDGDriver *wdgp) {

  osalDbgCheck(wdgp != NULL);

  osalSysLock();
  osalDbgAssert(wdgp->state == WDG_READY, "not ready");
  wdgResetI(wdgp);
  osalSysUnlock();
}

#endif /* HAL_USE_WDG == TRUE */

/** @} */
kt">void); void rgb_matrix_indicators_kb(void); void rgb_matrix_indicators_user(void); void rgb_matrix_init(void); void rgb_matrix_setup_drivers(void); void rgb_matrix_set_suspend_state(bool state); void rgb_matrix_set_indicator_state(uint8_t state); void rgb_matrix_task(void); // This should not be called from an interrupt // (eg. from a timer interrupt). // Call this while idle (in between matrix scans). // If the buffer is dirty, it will update the driver with the buffer. void rgb_matrix_update_pwm_buffers(void); bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record); void rgb_matrix_increase(void); void rgb_matrix_decrease(void); // void *backlight_get_key_color_eeprom_address(uint8_t led); // void backlight_get_key_color( uint8_t led, HSV *hsv ); // void backlight_set_key_color( uint8_t row, uint8_t column, HSV hsv ); void rgb_matrix_toggle(void); void rgb_matrix_enable(void); void rgb_matrix_enable_noeeprom(void); void rgb_matrix_disable(void); void rgb_matrix_disable_noeeprom(void); void rgb_matrix_step(void); void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val); void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val); void rgb_matrix_step_reverse(void); void rgb_matrix_increase_hue(void); void rgb_matrix_decrease_hue(void); void rgb_matrix_increase_sat(void); void rgb_matrix_decrease_sat(void); void rgb_matrix_increase_val(void); void rgb_matrix_decrease_val(void); void rgb_matrix_increase_speed(void); void rgb_matrix_decrease_speed(void); led_flags_t rgb_matrix_get_flags(void); void rgb_matrix_set_flags(led_flags_t flags); void rgb_matrix_mode(uint8_t mode); void rgb_matrix_mode_noeeprom(uint8_t mode); uint8_t rgb_matrix_get_mode(void); #ifndef RGBLIGHT_ENABLE #define rgblight_toggle() rgb_matrix_toggle() #define rgblight_enable() rgb_matrix_enable() #define rgblight_enable_noeeprom() rgb_matrix_enable_noeeprom() #define rgblight_disable() rgb_matrix_disable() #define rgblight_disable_noeeprom() rgb_matrix_disable_noeeprom() #define rgblight_step() rgb_matrix_step() #define rgblight_sethsv(hue, sat, val) rgb_matrix_sethsv(hue, sat, val) #define rgblight_sethsv_noeeprom(hue, sat, val) rgb_matrix_sethsv_noeeprom(hue, sat, val) #define rgblight_step_reverse() rgb_matrix_step_reverse() #define rgblight_increase_hue() rgb_matrix_increase_hue() #define rgblight_decrease_hue() rgb_matrix_decrease_hue() #define rgblight_increase_sat() rgb_matrix_increase_sat() #define rgblight_decrease_sat() rgb_matrix_decrease_sat() #define rgblight_increase_val() rgb_matrix_increase_val() #define rgblight_decrease_val() rgb_matrix_decrease_val() #define rgblight_increase_speed() rgb_matrix_increase_speed() #define rgblight_decrease_speed() rgb_matrix_decrease_speed() #define rgblight_mode(mode) rgb_matrix_mode(mode) #define rgblight_mode_noeeprom(mode) rgb_matrix_mode_noeeprom(mode) #define rgblight_get_mode() rgb_matrix_get_mode() #endif typedef struct { /* Perform any initialisation required for the other driver functions to work. */ void (*init)(void); /* Set the colour of a single LED in the buffer. */ void (*set_color)(int index, uint8_t r, uint8_t g, uint8_t b); /* Set the colour of all LEDS on the keyboard in the buffer. */ void (*set_color_all)(uint8_t r, uint8_t g, uint8_t b); /* Flush any buffered changes to the hardware. */ void (*flush)(void); } rgb_matrix_driver_t; extern const rgb_matrix_driver_t rgb_matrix_driver; extern rgb_config_t rgb_matrix_config; extern bool g_suspend_state; extern rgb_counters_t g_rgb_counters; extern led_config_t g_led_config; #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED extern last_hit_t g_last_hit_tracker; #endif #ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS extern uint8_t rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS]; #endif #endif