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 */

/** @} */
ODE to 1. */ #define _FS_RPATH 0 /* 0 to 2 */ /* The _FS_RPATH option configures relative path feature. / / 0: Disable relative path feature and remove related functions. / 1: Enable relative path. f_chdrive() and f_chdir() are available. / 2: f_getcwd() is available in addition to 1. / / Note that output of the f_readdir fnction is affected by this option. */ /*---------------------------------------------------------------------------/ / Physical Drive Configurations /----------------------------------------------------------------------------*/ #define _VOLUMES 1 /* Number of volumes (logical drives) to be used. */ #define _MAX_SS 512 /* 512, 1024, 2048 or 4096 */ /* Maximum sector size to be handled. / Always set 512 for memory card and hard disk but a larger value may be / required for on-board flash memory, floppy disk and optical disk. / When _MAX_SS is larger than 512, it configures FatFs to variable sector size / and GET_SECTOR_SIZE command must be implememted to the disk_ioctl function. */ #define _MULTI_PARTITION 0 /* 0:Single partition or 1:Multiple partition */ /* When set to 0, each volume is bound to the same physical drive number and / it can mount only first primaly partition. When it is set to 1, each volume / is tied to the partitions listed in VolToPart[]. */ #define _USE_ERASE 0 /* 0:Disable or 1:Enable */ /* To enable sector erase feature, set _USE_ERASE to 1. CTRL_ERASE_SECTOR command / should be added to the disk_ioctl functio. */ /*---------------------------------------------------------------------------/ / System Configurations /----------------------------------------------------------------------------*/ #define _WORD_ACCESS 1 /* 0 or 1 */ /* Set 0 first and it is always compatible with all platforms. The _WORD_ACCESS / option defines which access method is used to the word data on the FAT volume. / / 0: Byte-by-byte access. / 1: Word access. Do not choose this unless following condition is met. / / When the byte order on the memory is big-endian or address miss-aligned word / access results incorrect behavior, the _WORD_ACCESS must be set to 0. / If it is not the case, the value can also be set to 1 to improve the / performance and code size. */ /* A header file that defines sync object types on the O/S, such as / windows.h, ucos_ii.h and semphr.h, must be included prior to ff.h. */ #define _FS_REENTRANT 0 /* 0:Disable or 1:Enable */ #define _FS_TIMEOUT 1000 /* Timeout period in unit of time ticks */ #define _SYNC_t HANDLE /* O/S dependent type of sync object. e.g. HANDLE, OS_EVENT*, ID and etc.. */ /* The _FS_REENTRANT option switches the reentrancy (thread safe) of the FatFs module. / / 0: Disable reentrancy. _SYNC_t and _FS_TIMEOUT have no effect. / 1: Enable reentrancy. Also user provided synchronization handlers, / ff_req_grant, ff_rel_grant, ff_del_syncobj and ff_cre_syncobj / function must be added to the project. */ #define _FS_SHARE 0 /* 0:Disable or >=1:Enable */ /* To enable file shareing feature, set _FS_SHARE to 1 or greater. The value defines how many files can be opened simultaneously. */ #endif /* _FFCONFIG */