Revision a270d48f

View differences:

Target/Modules/PowerManagement_1-2/Boot/blt_conf.h
1
/************************************************************************************//**
2
* \file         Demo\ARMCM4_STM32_Olimex_STM32E407_GCC\Boot\blt_conf.h
3
* \brief        Bootloader configuration header file.
4
* \ingroup      Boot_ARMCM4_STM32_Olimex_STM32E407_GCC
5
* \internal
6
*----------------------------------------------------------------------------------------
7
*                          C O P Y R I G H T
8
*----------------------------------------------------------------------------------------
9
*   Copyright (c) 2013  by Feaser    http://www.feaser.com    All rights reserved
10
*
11
*----------------------------------------------------------------------------------------
12
*                            L I C E N S E
13
*----------------------------------------------------------------------------------------
14
* This file is part of OpenBLT. OpenBLT is free software: you can redistribute it and/or
15
* modify it under the terms of the GNU General Public License as published by the Free
16
* Software Foundation, either version 3 of the License, or (at your option) any later
17
* version.
18
*
19
* OpenBLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
20
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
21
* PURPOSE. See the GNU General Public License for more details.
22
*
23
* You should have received a copy of the GNU General Public License along with OpenBLT.
24
* If not, see <http://www.gnu.org/licenses/>.
25
*
26
* A special exception to the GPL is included to allow you to distribute a combined work
27
* that includes OpenBLT without being obliged to provide the source code for any
28
* proprietary components. The exception text is included at the bottom of the license
29
* file <license.html>.
30
*
31
* \endinternal
32
****************************************************************************************/
33
#ifndef BLT_CONF_H
34
#define BLT_CONF_H
35

  
36
/****************************************************************************************
37
*   C P U   D R I V E R   C O N F I G U R A T I O N
38
****************************************************************************************/
39
/* To properly initialize the baudrate clocks of the communication interface, typically
40
 * the speed of the crystal oscillator and/or the speed at which the system runs is
41
 * needed. Set these through configurables BOOT_CPU_XTAL_SPEED_KHZ and
42
 * BOOT_CPU_SYSTEM_SPEED_KHZ, respectively. To enable data exchange with the host that is
43
 * not dependent on the targets architecture, the byte ordering needs to be known.
44
 * Setting BOOT_CPU_BYTE_ORDER_MOTOROLA to 1 selects little endian mode and 0 selects
45
 * big endian mode.
46
 *
47
 * Set BOOT_CPU_USER_PROGRAM_START_HOOK to 1 if you would like a hook function to be
48
 * called the moment the user program is about to be started. This could be used to
49
 * de-initialize application specific parts, for example to stop blinking an LED, etc.
50
 */
51
/** \brief Frequency of the external crystal oscillator. */
52
#define BOOT_CPU_XTAL_SPEED_KHZ          (8000)
53
/** \brief Desired system speed. */
54
#define BOOT_CPU_SYSTEM_SPEED_KHZ        (168000)
55
/** \brief Motorola or Intel style byte ordering. */
56
#define BOOT_CPU_BYTE_ORDER_MOTOROLA     (0)
57
/** \brief Enable/disable hook function call right before user program start. */
58
#define BOOT_CPU_USER_PROGRAM_START_HOOK (1)
59

  
60

  
61
/****************************************************************************************
62
*   B O O T L O A D E R   O F   M A I N   D E V I C E
63
****************************************************************************************/
64
/* It is important to initialize if the bootloader is part of the main device. In this
65
 * case some backdoor loops have to stay opened and backdoor loops of other bootloaders
66
 * have to be controlled by this bootloader. Additionally the bootloader should be able
67
 * to send program code of user programs for other devices.
68
 * Make sure that one of the communication interfaces is the gateway!
69
 */
70
/** \brief Bootloader of main device. */
71
#define BOOTLOADER_OF_MAIN_DEVICE       (1)
72

  
73

  
74
/****************************************************************************************
75
*   C O M M U N I C A T I O N   I N T E R F A C E   C O N F I G U R A T I O N
76
****************************************************************************************/
77
/* The CAN communication interface is selected by setting the BOOT_COM_CAN_ENABLE
78
 * configurable to 1. Configurable BOOT_COM_CAN_BAUDRATE selects the communication speed
79
 * in bits/second. Two CAN messages are reserved for communication with the host. The
80
 * message identifier for sending data from the target to the host is configured with
81
 * BOOT_COM_CAN_TXMSG_ID. The one for receiving data from the host is configured with
82
 * BOOT_COM_CAN_RXMSG_ID. The maximum amount of data bytes in a message for data
83
 * transmission and reception is set through BOOT_COM_CAN_TX_MAX_DATA and
84
 * BOOT_COM_CAN_RX_MAX_DATA, respectively. It is common for a microcontroller to have more
85
 * than 1 CAN controller on board. The zero-based BOOT_COM_CAN_CHANNEL_INDEX selects the
86
 * CAN controller channel.
87
 *
88
 */
89
/** \brief Enable/disable CAN transport layer. */
90
#define BOOT_GATE_CAN_ENABLE            (1)
91
/** \brief Configure the desired CAN baudrate. */
92
#define BOOT_COM_CAN_BAUDRATE           (1000000)
93
/** \brief Configure CAN message ID target->host. */
94
#define BOOT_COM_CAN_TX_MSG_ID          (0x700)
95
/** \brief Configure number of bytes in the target->host CAN message. */
96
#define BOOT_COM_CAN_TX_MAX_DATA        (255)
97
/** \brief Configure CAN message ID host->target. */
98
#define BOOT_COM_CAN_RX_MSG_ID          (0x600)
99
/** \brief Configure number of bytes in the host->target CAN message. */
100
#define BOOT_COM_CAN_RX_MAX_DATA        (255)
101
/** \brief Select the desired CAN peripheral as a zero based index. */
102
#define BOOT_COM_CAN_CHANNEL_INDEX      (0)
103
/** \brief Configure CAN message acknowledgement ID addition (ORed with original ID). */
104
#define BOOT_COM_CAN_MSG_ACK            (0x001)
105
/** \brief Configure CAN message ID addition for continuous messages (ORed with original ID). */
106
#define BOOT_COM_CAN_MSG_SUBSEQUENT     (0x002)
107

  
108
/**
109
 * \brief Configure device ID for communication (start with 1).
110
 * \details The device ID is a 32 bit integer, which can be interpreted bytewise:
111
 *            <AMiRo_revision>:<moduleID>:<moduleVersion_major>:<moduleVersion_minor>
112
 *          For this module the according values are
113
 *            1:1:1:1 = 0x01010101
114
 */
115
#define BOOT_COM_DEVICE_ID              (0x01010102)
116

  
117

  
118
/* The UART communication interface is selected by setting the BOOT_COM_UART_ENABLE
119
 * configurable to 1. Configurable BOOT_COM_UART_BAUDRATE selects the communication speed
120
 * in bits/second. The maximum amount of data bytes in a message for data transmission
121
 * and reception is set through BOOT_COM_UART_TX_MAX_DATA and BOOT_COM_UART_RX_MAX_DATA,
122
 * respectively. It is common for a microcontroller to have more than 1 UART interface
123
 * on board. The zero-based BOOT_COM_UART_CHANNEL_INDEX selects the UART interface.
124
 *
125
 */
126
/** \brief Enable/disable UART transport layer. */
127
#define BOOT_COM_UART_ENABLE            (1)
128
/** \brief Enable/disable BLUETOOTH UART transport layer. */
129
#define BOOT_COM_BLUETOOTH_UART_ENABLE  (0)
130
/** \brief Configure the desired communication speed. */
131
#define BOOT_COM_UART_BAUDRATE          (115200)
132
/** \brief Configure number of bytes in the target->host data packet. */
133
#define BOOT_COM_UART_TX_MAX_DATA       (255)
134
/** \brief Configure number of bytes in the host->target data packet. */
135
#define BOOT_COM_UART_RX_MAX_DATA       (255)
136
/** \brief Select the desired UART peripheral as a zero based index. */
137
#define BOOT_COM_UART_CHANNEL_INDEX     (0)
138
/** \brief Select the desired BLUETOOTH UART peripheral as a zero based index. */
139
#define BOOT_COM_BLUETOOTH_UART_CHANNEL_INDEX (2)
140

  
141

  
142
/* The NET communication interface for firmware updates via TCP/IP is selected by setting
143
 * the BOOT_COM_NET_ENABLE configurable to 1. The maximum amount of data bytes in a
144
 * message for data transmission and reception is set through BOOT_COM_NET_TX_MAX_DATA
145
 * and BOOT_COM_NET_RX_MAX_DATA, respectively. The default IP address is configured
146
 * with the macros BOOT_COM_NET_IPADDRx. The default netmask is configued with the macros
147
 * BOOT_COM_NET_NETMASKx. The default gateway is configured with the macros
148
 * BOOT_COM_NET_GATEWAYx. The bootloader acts and a TCP/IP server. The port the server
149
 * listen on for connections is configured with BOOT_COM_NET_PORT.
150
 */
151
/** \brief Enable/disable the NET transport layer. */
152
#define BOOT_COM_NET_ENABLE              (0)
153
/** \brief Configure number of bytes in the target->host data packet. */
154
#define BOOT_COM_NET_TX_MAX_DATA         (64)
155
/** \brief Configure number of bytes in the host->target data packet. */
156
#define BOOT_COM_NET_RX_MAX_DATA         (64)
157
/** \brief Configure the port that the TCP/IP server listens on */
158
#define BOOT_COM_NET_PORT                (1000)
159
/** \brief Configure the 1st byte of the IP address */
160
#define BOOT_COM_NET_IPADDR0             (169)
161
/** \brief Configure the 2nd byte of the IP address */
162
#define BOOT_COM_NET_IPADDR1             (254)
163
/** \brief Configure the 3rd byte of the IP address */
164
#define BOOT_COM_NET_IPADDR2             (19)
165
/** \brief Configure the 4th byte of the IP address */
166
#define BOOT_COM_NET_IPADDR3             (63)
167
/** \brief Configure the 1st byte of the network mask */
168
#define BOOT_COM_NET_NETMASK0            (255)
169
/** \brief Configure the 2nd byte of the network mask */
170
#define BOOT_COM_NET_NETMASK1            (255)
171
/** \brief Configure the 3rd byte of the network mask */
172
#define BOOT_COM_NET_NETMASK2            (0)
173
/** \brief Configure the 4th byte of the network mask */
174
#define BOOT_COM_NET_NETMASK3            (0)
175
/** \brief Configure the 1st byte of the gateway address */
176
#define BOOT_COM_NET_GATEWAY0            (169)
177
/** \brief Configure the 2nd byte of the gateway address */
178
#define BOOT_COM_NET_GATEWAY1            (254)
179
/** \brief Configure the 3rd byte of the gateway address */
180
#define BOOT_COM_NET_GATEWAY2            (19)
181
/** \brief Configure the 4th byte of the gateway address */
182
#define BOOT_COM_NET_GATEWAY3            (1)
183
/** \brief Enable/disable a hook function that is called when the IP address is about
184
 *         to be set. This allows a dynamic override of the BOOT_COM_NET_IPADDRx values.
185
 */
186
#define BOOT_COM_NET_IPADDR_HOOK_ENABLE  (0)
187
/** \brief Enable/disable a hook function that is called when the netmask is about
188
 *         to be set. This allows a dynamic override of the BOOT_COM_NET_NETMASKx values.
189
 */
190
#define BOOT_COM_NET_NETMASK_HOOK_ENABLE (0)
191
/** \brief Enable/disable a hook function that is called when the gateway address is
192
 *         about to be set. This allows a dynamic override of the BOOT_COM_NET_GATEWAYx
193
 *         values.
194
 */
195
#define BOOT_COM_NET_GATEWAY_HOOK_ENABLE (0)
196

  
197

  
198
/****************************************************************************************
199
*   B A C K D O O R    C O N F I G U R A T I O N
200
****************************************************************************************/
201
#if (BOOT_COM_NET_ENABLE > 0)
202
/* Override the default time that the backdoor is open if firmware updates via TCP/IP
203
 * are supported. in this case a reactivation of the bootloader results in a re-
204
 * initialization of the ethernet MAC. when directly connected to the ethernet port of
205
 * a PC this will go relatively fast (depending on what MS Windows is being used), but
206
 * when connected to the network via a router this can take several seconds. feel free to
207
 * shorten/lengthen this time for finetuning. the only downside of a long backdoor open
208
 * time is that the starting of the user program will also be delayed for this time.
209
 *
210
 * Also note that when the target is directly connected to the ethernet port of a PC,
211
 * the checkbox "Automatically retry socket connection" should be checked in the
212
 * Microboot settings. if connecting via a router the uncheck this checkbox.
213
 */
214
#define BACKDOOR_ENTRY_TIMEOUT_MS  (10000)
215
#endif
216

  
217

  
218
/****************************************************************************************
219
*   F I L E   S Y S T E M   I N T E R F A C E   C O N F I G U R A T I O N
220
****************************************************************************************/
221
/* The file system interface is selected by setting the BOOT_FILE_SYS_ENABLE configurable
222
 * to 1. This enables support for firmware updates from a file stored on a locally
223
 * attached file system such as an SD-card. Note that this interface can be enabled
224
 * together with one of the remote communication interfaces such as UART, CAN or USB.
225
 *
226
 * Set BOOT_FILE_LOGGING_ENABLE to 1 if you would like log messages to be created during
227
 * a firmware update. The hook function FileFirmwareUpdateLogHook() will be called each
228
 * time a new string formatted log entry is available. This could be used during testing
229
 * by outputting the string on UART or to create a log file on the file system itself.
230
 *
231
 * Set BOOT_FILE_ERROR_HOOK_ENABLE to 1 if you would like to be informed in case an error
232
 * occurs during the firmware update. This could for example be used to turn on an error
233
 * LED to inform the user that something went wrong. Inspecting the log messages provides
234
 * additional information on the error cause.
235
 *
236
 * Set BOOT_FILE_STARTED_HOOK_ENABLE to 1 if you would like to be informed when a new
237
 * firmware update is started by the bootloader.
238
 *
239
 * Set BOOT_FILE_COMPLETED_HOOK_ENABLE to 1 if you would like to be informed when a
240
 * firmware update is completed by the bootloader.
241
 */
242
/** \brief Enable/disable support for firmware updates from a locally attached storage.*/
243
#define BOOT_FILE_SYS_ENABLE            (0)
244
/** \brief Enable/disable logging messages during firmware updates. */
245
#define BOOT_FILE_LOGGING_ENABLE        (1)
246
/** \brief Enable/disable a hook function that is called upon detection of an error. */
247
#define BOOT_FILE_ERROR_HOOK_ENABLE     (1)
248
/** \brief Enable/disable a hook function that is called at the start of the update. */
249
#define BOOT_FILE_STARTED_HOOK_ENABLE   (1)
250
/** \brief Enable/disable a hook function that is called at the end of the update. */
251
#define BOOT_FILE_COMPLETED_HOOK_ENABLE (1)
252

  
253

  
254
/****************************************************************************************
255
*   B A C K D O O R   E N T R Y   C O N F I G U R A T I O N
256
****************************************************************************************/
257
/* It is possible to implement an application specific method to force the bootloader to
258
 * stay active after a reset. Such a backdoor entry into the bootloader is desired in
259
 * situations where the user program does not run properly and therefore cannot
260
 * reactivate the bootloader. By enabling these hook functions, the application can
261
 * implement the backdoor, which overrides the default backdoor entry that is programmed
262
 * into the bootloader. When desired for security purposes, these hook functions can
263
 * also be implemented in a way that disables the backdoor entry altogether.
264
 */
265
/** \brief Enable/disable the backdoor override hook functions. */
266
#define BOOT_BACKDOOR_HOOKS_ENABLE      (1)
267

  
268

  
269
/****************************************************************************************
270
*   N O N - V O L A T I L E   M E M O R Y   D R I V E R   C O N F I G U R A T I O N
271
****************************************************************************************/
272
/* The NVM driver typically supports erase and program operations of the internal memory
273
 * present on the microcontroller. Through these hook functions the NVM driver can be
274
 * extended to support additional memory types such as external flash memory and serial
275
 * eeproms. The size of the internal memory in kilobytes is specified with configurable
276
 * BOOT_NVM_SIZE_KB. If desired the internal checksum writing and verification method can
277
 * be overridden with a application specific method by enabling configuration switch
278
 * BOOT_NVM_CHECKSUM_HOOKS_ENABLE.
279
 */
280
/** \brief Enable/disable the NVM hook function for supporting additional memory devices. */
281
#define BOOT_NVM_HOOKS_ENABLE           (0)
282
/** \brief Configure the size of the default memory device (typically flash EEPROM). */
283
#define BOOT_NVM_SIZE_KB                (1024)
284
/** \brief Enable/disable hooks functions to override the user program checksum handling. */
285
#define BOOT_NVM_CHECKSUM_HOOKS_ENABLE  (0)
286

  
287

  
288
/****************************************************************************************
289
*   W A T C H D O G   D R I V E R   C O N F I G U R A T I O N
290
****************************************************************************************/
291
/* The COP driver cannot be configured internally in the bootloader, because its use
292
 * and configuration is application specific. The bootloader does need to service the
293
 * watchdog in case it is used. When the application requires the use of a watchdog,
294
 * set BOOT_COP_HOOKS_ENABLE to be able to initialize and service the watchdog through
295
 * hook functions.
296
 */
297
/** \brief Enable/disable the hook functions for controlling the watchdog. */
298
#define BOOT_COP_HOOKS_ENABLE           (0)
299

  
300

  
301
/****************************************************************************************
302
*   S E E D / K E Y   S E C U R I T Y   C O N F I G U R A T I O N
303
****************************************************************************************/
304
/* A security mechanism can be enabled in the bootloader's XCP module by setting configu-
305
 * rable BOOT_XCP_SEED_KEY_ENABLE to 1. Before any memory erase or programming
306
 * operations can be performed, access to this resource need to be unlocked.
307
 * In the Microboot settings on tab "XCP Protection" you need to specify a DLL that
308
 * implements the unlocking algorithm. The demo programs are configured for the (simple)
309
 * algorithm in "FeaserKey.dll". The source code for this DLL is available so it can be
310
 * customized to your needs.
311
 * During the unlock sequence, Microboot requests a seed from the bootloader, which is in
312
 * the format of a byte array. Using this seed the unlock algorithm in the DLL computes
313
 * a key, which is also a byte array, and sends this back to the bootloader. The
314
 * bootloader then verifies this key to determine if programming and erase operations are
315
 * permitted.
316
 * After enabling this feature the hook functions XcpGetSeedHook() and XcpVerifyKeyHook()
317
 * are called by the bootloader to obtain the seed and to verify the key, respectively.
318
 */
319
#define BOOT_XCP_SEED_KEY_ENABLE        (0)
320

  
321

  
322
#endif /* BLT_CONF_H */
323
/*********************************** end of blt_conf.h *********************************/
Target/Modules/PowerManagement_1-2/Boot/boot.dox
1
/**
2
\defgroup   Boot_ARMCM4_STM32_Olimex_STM32E407_GCC Bootloader
3
\brief      Bootloader. 
4
\ingroup    ARMCM4_STM32_Olimex_STM32E407_GCC
5
*/
6

  
7

  
Target/Modules/PowerManagement_1-2/Boot/cmd/build.bat
1
@echo off
2
cs-make --directory=../ all
Target/Modules/PowerManagement_1-2/Boot/cmd/clean.bat
1
@echo off
2
cs-make --directory=../ clean
Target/Modules/PowerManagement_1-2/Boot/hooks.c
1
/************************************************************************************//**
2
* \file         Demo\ARMCM3_STM32_Olimex_STM32P103_GCC\Boot\hooks.c
3
* \brief        Bootloader callback source file.
4
* \ingroup      Boot_ARMCM3_STM32_Olimex_STM32P103_GCC
5
* \internal
6
*----------------------------------------------------------------------------------------
7
*                          C O P Y R I G H T
8
*----------------------------------------------------------------------------------------
9
*   Copyright (c) 2012  by Feaser    http://www.feaser.com    All rights reserved
10
*
11
*----------------------------------------------------------------------------------------
12
*                            L I C E N S E
13
*----------------------------------------------------------------------------------------
14
* This file is part of OpenBLT. OpenBLT is free software: you can redistribute it and/or
15
* modify it under the terms of the GNU General Public License as published by the Free
16
* Software Foundation, either version 3 of the License, or (at your option) any later
17
* version.
18
*
19
* OpenBLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
20
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
21
* PURPOSE. See the GNU General Public License for more details.
22
*
23
* You should have received a copy of the GNU General Public License along with OpenBLT.
24
* If not, see <http://www.gnu.org/licenses/>.
25
*
26
* A special exception to the GPL is included to allow you to distribute a combined work 
27
* that includes OpenBLT without being obliged to provide the source code for any 
28
* proprietary components. The exception text is included at the bottom of the license
29
* file <license.html>.
30
* 
31
* \endinternal
32
****************************************************************************************/
33

  
34
/****************************************************************************************
35
* Include files
36
****************************************************************************************/
37
#include "boot.h"                                /* bootloader generic header          */
38
#if (BOOT_FILE_LOGGING_ENABLE > 0)
39
#include "stm32f4xx.h"                           /* STM32 registers                    */
40
#include "stm32f4xx_conf.h"                      /* STM32 peripheral drivers           */
41
#endif
42

  
43

  
44
/****************************************************************************************
45
*   B A C K D O O R   E N T R Y   H O O K   F U N C T I O N S
46
****************************************************************************************/
47

  
48
#if (BOOT_BACKDOOR_HOOKS_ENABLE > 0)
49

  
50
static blt_int32u backdoorOpenTime;
51
#define BACKDOOR_ENTRY_TIMEOUT_MS 500
52
static blt_bool timeRanOut = BLT_FALSE;
53
static blt_int32u osSyncTime;
54
#define OS_SYNC_MS 1
55
#define OS_WAIT_MS 1
56
enum BOOT_STATE {BOOT_FLASH_CHECK,
57
                 BOOT_FLASH_WAIT,
58
                 BOOT_OS_SYNC,
59
                 BOOT_OS_START,
60
                 BOOT_OS_WAIT
61
                } boot_state;
62

  
63
#define SYS_PD_N_PIN        GPIO_Pin_13
64
#define SYS_PD_N_GPIO       GPIOC
65
#define SYS_SYNC_N_PIN      GPIO_Pin_12
66
#define SYS_SYNC_N_GPIO     GPIOC
67
#define BT_RST_PIN          GPIO_Pin_15
68
#define BT_RST_GPIO         GPIOC
69

  
70
/************************************************************************************//**
71
** \brief     Initializes the backdoor entry option.
72
** \return    none.
73
**
74
****************************************************************************************/
75
void BackDoorInitHook(void)
76
{
77
  backdoorOpenTime = TimerGet();
78
  boot_state = BOOT_FLASH_CHECK;
79
} /*** end of BackDoorInitHook ***/
80

  
81

  
82
/************************************************************************************//**
83
** \brief     Checks if it has to stay in backdoor.
84
** \return    BLT_TRUE if the backdoor entry is requested, BLT_FALSE otherwise.
85
**
86
****************************************************************************************/
87
blt_bool BackDoorEntryCheck(void) {
88
  /* evaluate the fsm state */
89
  switch (boot_state) {
90
    case BOOT_FLASH_CHECK:
91
    {
92
      /* wait for a timeout */
93
      if (timeRanOut == BLT_FALSE) {
94
        if (TimerGet() > backdoorOpenTime+BACKDOOR_ENTRY_TIMEOUT_MS) {
95
          timeRanOut = BLT_TRUE;
96
          boot_state = BOOT_FLASH_WAIT;
97
          GPIO_SetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN);
98
        }
99
      }
100
      return BLT_TRUE;
101
      break;
102
    }
103
    case BOOT_FLASH_WAIT:
104
    {
105
      /* wait for the SYS_SYNC_N signal to go up */
106
      if (GPIO_ReadInputDataBit(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN) == Bit_RESET) {
107
        return BLT_TRUE;
108
      } else {
109
        osSyncTime = TimerGet();
110
        boot_state = BOOT_OS_SYNC;
111
        return BLT_FALSE;
112
      }
113
      break;
114
    }
115
    default:
116
      return BLT_FALSE;
117
      break;
118
  }
119
  return BLT_FALSE;
120
}
121

  
122
/************************************************************************************//**
123
** \brief     Checks if a backdoor entry is requested.
124
** \return    BLT_TRUE if the backdoor entry is requested, BLT_FALSE otherwise.
125
**
126
****************************************************************************************/
127
blt_bool BackDoorEntryHook(void)
128
{
129
  /* default implementation always activates the bootloader after a reset */
130
  return BLT_TRUE;
131
} /*** end of BackDoorEntryHook ***/
132
#endif /* BOOT_BACKDOOR_HOOKS_ENABLE > 0 */
133

  
134

  
135
/************************************************************************************//**
136
** \brief     Notice that there is still an open connection over COM 
137
** \return    -
138
**
139
****************************************************************************************/
140
void BackDoorComIsConnected(void)
141
{
142
  backdoorOpenTime = TimerGet();
143
}
144

  
145

  
146
/****************************************************************************************
147
*   C P U   D R I V E R   H O O K   F U N C T I O N S
148
****************************************************************************************/
149

  
150
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
151

  
152
#if (BOOT_COM_BLUETOOTH_UART_CHANNEL_INDEX == 0)
153
/** \brief Set BLUETOOTH UART base address to USART1. */
154
#define BLUETOOTH_USART_CHANNEL   USART1
155
#elif (BOOT_COM_BLUETOOTH_UART_CHANNEL_INDEX == 1)
156
/** \brief Set BLUETOOTH UART base address to USART2. */
157
#define BLUETOOTH_USART_CHANNEL   USART2
158
#elif (BOOT_COM_BLUETOOTH_UART_CHANNEL_INDEX == 2)
159
/** \brief Set BLUETOOTH UART base address to USART3. */
160
#define BLUETOOTH_USART_CHANNEL   USART3
161
#elif (BOOT_COM_BLUETOOTH_UART_CHANNEL_INDEX == 3)
162
/** \brief Set BLUETOOTH UART base address to USART4. */
163
#define BLUETOOTH_USART_CHANNEL   USART4
164
#elif (BOOT_COM_BLUETOOTH_UART_CHANNEL_INDEX == 4)
165
/** \brief Set BLUETOOTH UART base address to USART5. */
166
#define BLUETOOTH_USART_CHANNEL   USART5
167
#elif (BOOT_COM_BLUETOOTH_UART_CHANNEL_INDEX == 5)
168
/** \brief Set BLUETOOTH UART base address to USART6. */
169
#define BLUETOOTH_USART_CHANNEL   USART6
170
#endif
171
/************************************************************************************//**
172
** \brief     Callback that gets called when the bootloader is about to exit and
173
**            hand over control to the user program. This is the last moment that
174
**            some final checking can be performed and if necessary prevent the
175
**            bootloader from activiting the user program.
176
** \return    BLT_TRUE if it is okay to start the user program, BLT_FALSE to keep
177
**            keep the bootloader active.
178
**
179
****************************************************************************************/
180
blt_bool CpuUserProgramStartHook(void)
181
{
182
  /* evaluate the fsm state */
183
  switch (boot_state) {
184
    case BOOT_OS_SYNC:
185
    {
186
      /* wait some time so all modules can detect the high SYS_SYNC_N signal */
187

  
188
      GPIO_SetBits(BT_RST_GPIO, BT_RST_PIN);
189
      USART_Cmd(BLUETOOTH_USART_CHANNEL, DISABLE);
190
      USART_DeInit(BLUETOOTH_USART_CHANNEL);
191

  
192
      if (TimerGet() > osSyncTime + OS_SYNC_MS) {
193
        boot_state = BOOT_OS_START;
194
      }
195
      return BLT_FALSE;
196
      break;
197
    }
198
    case BOOT_OS_START:
199
    {
200
      /* pull down SYS_SYNC_N to indicate that all modules shall exit the bootloader and start the OS */
201

  
202
      GPIO_ResetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN);
203
      osSyncTime = TimerGet();
204
      boot_state = BOOT_OS_WAIT;
205

  
206
      return BLT_FALSE;
207
      break;
208
    }
209
    case BOOT_OS_WAIT:
210
    {
211
      /* wait some time so all module can detect the low SYS_SYNC_N signal */
212

  
213
      if (TimerGet() > osSyncTime + OS_WAIT_MS) {
214
        return BLT_TRUE;
215
      } else {
216
        return BLT_FALSE;
217
      }
218
    }
219
    default:
220
      return BLT_FALSE;
221
      break;
222
  }
223

  
224
  /* okay to start the user program */
225
  return BLT_TRUE;
226
} /*** end of CpuUserProgramStartHook ***/
227
#endif /* BOOT_CPU_USER_PROGRAM_START_HOOK > 0 */
228

  
229

  
230
/****************************************************************************************
231
*   N O N - V O L A T I L E   M E M O R Y   D R I V E R   H O O K   F U N C T I O N S
232
****************************************************************************************/
233

  
234
#if (BOOT_NVM_HOOKS_ENABLE > 0)
235
/************************************************************************************//**
236
** \brief     Callback that gets called at the start of the internal NVM driver
237
**            initialization routine. 
238
** \return    none.
239
**
240
****************************************************************************************/
241
void NvmInitHook(void)
242
{
243
} /*** end of NvmInitHook ***/
244

  
245

  
246
/************************************************************************************//**
247
** \brief     Callback that gets called at the start of the NVM driver write 
248
**            routine. It allows additional memory to be operated on. If the address
249
**            is not within the range of the additional memory, then 
250
**            BLT_NVM_NOT_IN_RANGE must be returned to indicate that the data hasn't
251
**            been written yet.
252
** \param     addr Start address.
253
** \param     len  Length in bytes.
254
** \param     data Pointer to the data buffer.
255
** \return    BLT_NVM_OKAY if successful, BLT_NVM_NOT_IN_RANGE if the address is
256
**            not within the supported memory range, or BLT_NVM_ERROR is the write
257
**            operation failed.
258
**
259
****************************************************************************************/
260
blt_int8u NvmWriteHook(blt_addr addr, blt_int32u len, blt_int8u *data)
261
{
262
  return BLT_NVM_NOT_IN_RANGE;
263
} /*** end of NvmWriteHook ***/
264

  
265

  
266
/************************************************************************************//**
267
** \brief     Callback that gets called at the start of the NVM driver erase 
268
**            routine. It allows additional memory to be operated on. If the address
269
**            is not within the range of the additional memory, then
270
**            BLT_NVM_NOT_IN_RANGE must be returned to indicate that the memory
271
**            hasn't been erased yet.
272
** \param     addr Start address.
273
** \param     len  Length in bytes.
274
** \return    BLT_NVM_OKAY if successful, BLT_NVM_NOT_IN_RANGE if the address is
275
**            not within the supported memory range, or BLT_NVM_ERROR is the erase
276
**            operation failed.
277
**
278
****************************************************************************************/
279
blt_int8u NvmEraseHook(blt_addr addr, blt_int32u len)
280
{
281
  return BLT_NVM_NOT_IN_RANGE;
282
} /*** end of NvmEraseHook ***/
283

  
284

  
285
/************************************************************************************//**
286
** \brief     Callback that gets called at the end of the NVM programming session.
287
** \return    BLT_TRUE is successful, BLT_FALSE otherwise.
288
**
289
****************************************************************************************/
290
blt_bool NvmDoneHook(void)
291
{
292
  return BLT_TRUE;
293
} /*** end of NvmDoneHook ***/
294
#endif /* BOOT_NVM_HOOKS_ENABLE > 0 */
295

  
296

  
297
#if (BOOT_NVM_CHECKSUM_HOOKS_ENABLE > 0)
298
/************************************************************************************//**
299
** \brief     Verifies the checksum, which indicates that a valid user program is
300
**            present and can be started.
301
** \return    BLT_TRUE if successful, BLT_FALSE otherwise.
302
**
303
****************************************************************************************/
304
blt_bool NvmVerifyChecksumHook(void)
305
{
306
  return BLT_TRUE;
307
} /*** end of NvmVerifyChecksum ***/
308

  
309

  
310
/************************************************************************************//**
311
** \brief     Writes a checksum of the user program to non-volatile memory. This is
312
**            performed once the entire user program has been programmed. Through
313
**            the checksum, the bootloader can check if a valid user programming is
314
**            present and can be started.
315
** \return    BLT_TRUE if successful, BLT_FALSE otherwise. 
316
**
317
****************************************************************************************/
318
blt_bool NvmWriteChecksumHook(void)
319
{
320
  return BLT_TRUE;
321
}
322
#endif /* BOOT_NVM_CHECKSUM_HOOKS_ENABLE > 0 */
323

  
324

  
325
/****************************************************************************************
326
*   W A T C H D O G   D R I V E R   H O O K   F U N C T I O N S
327
****************************************************************************************/
328

  
329
#if (BOOT_COP_HOOKS_ENABLE > 0)
330
/************************************************************************************//**
331
** \brief     Callback that gets called at the end of the internal COP driver
332
**            initialization routine. It can be used to configure and enable the
333
**            watchdog.
334
** \return    none.
335
**
336
****************************************************************************************/
337
void CopInitHook(void)
338
{
339
} /*** end of CopInitHook ***/
340

  
341

  
342
/************************************************************************************//**
343
** \brief     Callback that gets called at the end of the internal COP driver
344
**            service routine. This gets called upon initialization and during
345
**            potential long lasting loops and routine. It can be used to service
346
**            the watchdog to prevent a watchdog reset.
347
** \return    none.
348
**
349
****************************************************************************************/
350
void CopServiceHook(void)
351
{
352
} /*** end of CopServiceHook ***/
353
#endif /* BOOT_COP_HOOKS_ENABLE > 0 */
354

  
355

  
356
/****************************************************************************************
357
*   F I L E   S Y S T E M   I N T E R F A C E   H O O K   F U N C T I O N S
358
****************************************************************************************/
359

  
360
#if (BOOT_FILE_SYS_ENABLE > 0)
361

  
362
/****************************************************************************************
363
* Constant data declarations
364
****************************************************************************************/
365
/** \brief Firmware filename. */
366
static const blt_char firmwareFilename[] = "/demoprog_olimex_stm32p103.srec";
367

  
368

  
369
/****************************************************************************************
370
* Local data declarations
371
****************************************************************************************/
372
#if (BOOT_FILE_LOGGING_ENABLE > 0)
373
/** \brief Data structure for grouping log-file related information. */
374
static struct 
375
{
376
  FIL      handle;                  /**< FatFS handle to the log-file.                 */
377
  blt_bool canUse;                  /**< Flag to indicate if the log-file can be used. */
378
} logfile;
379
#endif
380

  
381

  
382
/************************************************************************************//**
383
** \brief     Callback that gets called to check whether a firmware update from 
384
**            local file storage should be started. This could for example be when
385
**            a switch is pressed, when a certain file is found on the local file 
386
**            storage, etc.
387
** \return    BLT_TRUE if a firmware update is requested, BLT_FALSE otherwise.
388
**
389
****************************************************************************************/
390
blt_bool FileIsFirmwareUpdateRequestedHook(void)
391
{
392
  FILINFO fileInfoObject = { 0 }; /* needs to be zeroed according to f_stat docs */;
393

  
394
  /* Current example implementation looks for a predetermined firmware file on the 
395
   * SD-card. If the SD-card is accessible and the firmware file was found the firmware
396
   * update is started. When successfully completed, the firmware file is deleted.
397
   * During the firmware update, progress information is written to a file called
398
   * bootlog.txt and additionally outputted on UART @57600 bps for debugging purposes.
399
   */
400
  /* check if firmware file is present and SD-card is accessible */
401
  if (f_stat(firmwareFilename, &fileInfoObject) == FR_OK) 
402
  {
403
    /* check if the filesize is valid and that it is not a directory */
404
    if ( (fileInfoObject.fsize > 0) && (!(fileInfoObject.fattrib & AM_DIR)) )
405
    {
406
      /* all conditions are met to start a firmware update from local file storage */
407
      return BLT_TRUE;
408
    }
409
  }
410
  /* still here so no firmware update request is pending */  
411
  return BLT_FALSE;
412
} /*** end of FileIsFirmwareUpdateRequestedHook ***/
413

  
414

  
415
/************************************************************************************//**
416
** \brief     Callback to obtain the filename of the firmware file that should be
417
**            used during the firmware update from the local file storage. This 
418
**            hook function is called at the beginning of the firmware update from
419
**            local storage sequence. 
420
** \return    valid firmware filename with full path or BLT_NULL.
421
**
422
****************************************************************************************/
423
const blt_char *FileGetFirmwareFilenameHook(void)
424
{
425
  return firmwareFilename;
426
} /*** end of FileGetFirmwareFilenameHook ***/
427

  
428

  
429
#if (BOOT_FILE_STARTED_HOOK_ENABLE > 0)
430
/************************************************************************************//**
431
** \brief     Callback that gets called to inform the application that a firmware
432
**            update from local storage just started. 
433
** \return    none.
434
**
435
****************************************************************************************/
436
void FileFirmwareUpdateStartedHook(void)
437
{
438
  #if (BOOT_FILE_LOGGING_ENABLE > 0)
439
  /* create/overwrite the logfile */
440
  logfile.canUse = BLT_FALSE;
441
  if (f_open(&logfile.handle, "/bootlog.txt", FA_CREATE_ALWAYS | FA_WRITE) == FR_OK)
442
  {
443
    logfile.canUse = BLT_TRUE;
444
  }
445
  #endif
446
} /*** end of FileFirmwareUpdateStartedHook ***/
447
#endif /* BOOT_FILE_STARTED_HOOK_ENABLE > 0 */
448

  
449

  
450
#if (BOOT_FILE_COMPLETED_HOOK_ENABLE > 0)
451
/************************************************************************************//**
452
** \brief     Callback that gets called to inform the application that a firmware
453
**            update was successfully completed.
454
** \return    none.
455
**
456
****************************************************************************************/
457
void FileFirmwareUpdateCompletedHook(void)
458
{
459
  #if (BOOT_FILE_LOGGING_ENABLE > 0)
460
  /* close the log file */
461
  if (logfile.canUse == BLT_TRUE)
462
  {
463
    f_close(&logfile.handle);
464
  }
465
  /* wait for all logging related transmission to complete */
466
  while(USART_GetFlagStatus(USART2, USART_FLAG_TC) == RESET);
467
  #endif
468
  /* now delete the firmware file from the disk since the update was successful */
469
  f_unlink(firmwareFilename);
470
} /*** end of FileFirmwareUpdateCompletedHook ***/
471
#endif /* BOOT_FILE_COMPLETED_HOOK_ENABLE > 0 */
472

  
473

  
474
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
475
/************************************************************************************//**
476
** \brief     Callback that gets called in case an error occurred during a firmware
477
**            update. Refer to <file.h> for a list of available error codes.
478
** \return    none.
479
**
480
****************************************************************************************/
481
void FileFirmwareUpdateErrorHook(blt_int8u error_code)
482
{
483
  #if (BOOT_FILE_LOGGING_ENABLE > 0)
484
  /* error detected which stops the firmware update, so close the log file */
485
  if (logfile.canUse == BLT_TRUE)
486
  {
487
    f_close(&logfile.handle);
488
  }
489
  #endif
490
} /*** end of FileFirmwareUpdateErrorHook ***/
491
#endif /* BOOT_FILE_ERROR_HOOK_ENABLE > 0 */
492

  
493

  
494
#if (BOOT_FILE_LOGGING_ENABLE > 0)
495
/************************************************************************************//**
496
** \brief     Callback that gets called each time new log information becomes 
497
**            available during a firmware update.
498
** \param     info_string Pointer to a character array with the log entry info.
499
** \return    none.
500
**
501
****************************************************************************************/
502
void FileFirmwareUpdateLogHook(blt_char *info_string)
503
{
504
  /* write the string to the log file */
505
  if (logfile.canUse == BLT_TRUE)
506
  {
507
    if (f_puts(info_string, &logfile.handle) < 0)
508
    {
509
      logfile.canUse = BLT_FALSE;
510
      f_close(&logfile.handle);
511
    }
512
  }
513
  /* echo all characters in the string on UART */
514
  while(*info_string != '\0')
515
  {
516
    /* write character to transmit holding register */
517
    USART_SendData(USART2, *info_string);
518
    /* wait for tx holding register to be empty */
519
    while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET);
520
    /* point to the next character in the string */
521
    info_string++;
522
  }
523
} /*** end of FileFirmwareUpdateLogHook ***/
524
#endif /* BOOT_FILE_LOGGING_ENABLE > 0 */
525

  
526

  
527
#endif /* BOOT_FILE_SYS_ENABLE > 0 */
528

  
529

  
530
/****************************************************************************************
531
*   S E E D / K E Y   S E C U R I T Y   H O O K   F U N C T I O N S
532
****************************************************************************************/
533

  
534
#if (BOOT_XCP_SEED_KEY_ENABLE > 0)
535
/************************************************************************************//**
536
** \brief     Provides a seed to the XCP master that will be used for the key 
537
**            generation when the master attempts to unlock the specified resource. 
538
**            Called by the GET_SEED command.
539
** \param     resource  Resource that the seed if requested for (XCP_RES_XXX).
540
** \param     seed      Pointer to byte buffer wher the seed will be stored.
541
** \return    Length of the seed in bytes.
542
**
543
****************************************************************************************/
544
blt_int8u XcpGetSeedHook(blt_int8u resource, blt_int8u *seed)
545
{
546
  /* request seed for unlocking ProGraMming resource */
547
  if ((resource & XCP_RES_PGM) != 0)
548
  {
549
    seed[0] = 0x55;
550
  }
551

  
552
  /* return seed length */
553
  return 1;
554
} /*** end of XcpGetSeedHook ***/
555

  
556

  
557
/************************************************************************************//**
558
** \brief     Called by the UNLOCK command and checks if the key to unlock the 
559
**            specified resource was correct. If so, then the resource protection 
560
**            will be removed.
561
** \param     resource  resource to unlock (XCP_RES_XXX).
562
** \param     key       pointer to the byte buffer holding the key.
563
** \param     len       length of the key in bytes.
564
** \return    1 if the key was correct, 0 otherwise.
565
**
566
****************************************************************************************/
567
blt_int8u XcpVerifyKeyHook(blt_int8u resource, blt_int8u *key, blt_int8u len)
568
{
569
  /* suppress compiler warning for unused parameter */
570
  len = len;
571

  
572
  /* the example key algorithm in "FeaserKey.dll" works as follows:
573
   *  - PGM will be unlocked if key = seed - 1
574
   */
575

  
576
  /* check key for unlocking ProGraMming resource */
577
  if ((resource == XCP_RES_PGM) && (key[0] == (0x55-1)))
578
  {
579
    /* correct key received for unlocking PGM resource */
580
    return 1;
581
  }
582

  
583
  /* still here so key incorrect */
584
  return 0;
585
} /*** end of XcpVerifyKeyHook ***/
586
#endif /* BOOT_XCP_SEED_KEY_ENABLE > 0 */
587

  
588

  
589
/*********************************** end of hooks.c ************************************/
Target/Modules/PowerManagement_1-2/Boot/iodef.h
1
#ifndef IODEF_H
2
#define IODEF_H
3

  
4
#include "stm32f4xx.h"
5
#include "stm32f4xx_conf.h"
6

  
7
#define WKUP_GPIO               GPIOA
8
#define WKUP_PIN                GPIO_Pin_0
9
#define SWITCH_STATUS_N_GPIO    GPIOA
10
#define SWITCH_STATUS_N_PIN     GPIO_Pin_1
11
#define SYS_UART_TX_GPIO        GPIOA
12
#define SYS_UART_TX_PIN         GPIO_Pin_2
13
#define SYS_UART_RX_GPIO        GPIOA
14
#define SYS_UART_RX_PIN         GPIO_Pin_3
15
#define SYS_SPI_SS0_N_GPIO      GPIOA
16
#define SYS_SPI_SS0_N_PIN       GPIO_Pin_4
17
#define SYS_SPI_SCLK_GPIO       GPIOA
18
#define SYS_SPI_SCLK_PIN        GPIO_Pin_5
19
#define SYS_SPI_MISO_GPIO       GPIOA
20
#define SYS_SPI_MISO_PIN        GPIO_Pin_6
21
#define SYS_SPI_MOSI_GPIO       GPIOA
22
#define SYS_SPI_MOSI_PIN        GPIO_Pin_7
23
#define SYS_REG_EN_GPIO         GPIOA
24
#define SYS_REG_EN_PIN          GPIO_Pin_8
25
#define PROG_RX_GPIO            GPIOA
26
#define PROG_RX_PIN             GPIO_Pin_9
27
#define PROG_TX_GPIO            GPIOA
28
#define PROG_TX_PIN             GPIO_Pin_10
29
#define CAN_RX_GPIO             GPIOA
30
#define CAN_RX_PIN              GPIO_Pin_11
31
#define CAN_TX_GPIO             GPIOA
32
#define CAN_TX_PIN              GPIO_Pin_12
33
#define SWDIO_GPIO              GPIOA
34
#define SWDIO_PIN               GPIO_Pin_13
35
#define SWCLK_GPIO              GPIOA
36
#define SWCLK_PIN               GPIO_Pin_14
37
#define SYS_SPI_SS1_N_GPIO      GPIOA
38
#define SYS_SPI_SS1_N_PIN       GPIO_Pin_15
39

  
40
#define IR_INT1_N_GPIO          GPIOB
41
#define IR_INT1_N_PIN           GPIO_Pin_0
42
#define VSYS_SENSE_GPIO         GPIOB
43
#define VSYS_SENSE_PIN          GPIO_Pin_1
44
#define POWER_EN_GPIO           GPIOB
45
#define POWER_EN_PIN            GPIO_Pin_2
46
#define SYS_UART_DN_GPIO        GPIOB
47
#define SYS_UART_DN_PIN         GPIO_Pin_3
48
#define CHARGE_STAT2A_GPIO      GPIOB
49
#define CHARGE_STAT2A_PIN       GPIO_Pin_4
50
#define BUZZER_GPIO             GPIOB
51
#define BUZZER_PIN              GPIO_Pin_5
52
#define GAUGE_BATLOW2_GPIO      GPIOB
53
#define GAUGE_BATLOW2_PIN       GPIO_Pin_6
54
#define GAUGE_BATGD2_N_GPIO     GPIOB
55
#define GAUGE_BATGD2_N_PIN      GPIO_Pin_7
56
#define GAUGE_SCL2_GPIO         GPIOB
57
#define GAUGE_SCL2_PIN          GPIO_Pin_8
58
#define GAUGE_SDA2_GPIO         GPIOB
59
#define GAUGE_SDA2_PIN          GPIO_Pin_9
60
#define GAUGE_SCL1_GPIO         GPIOB
61
#define GAUGE_SCL1_PIN          GPIO_Pin_10
62
#define GAUGE_SDA1_GPIO         GPIOB
63
#define GAUGE_SDA1_PIN          GPIO_Pin_11
64
#define LED_GPIO                GPIOB
65
#define LED_PIN                 GPIO_Pin_12
66
#define BT_RTS_GPIO             GPIOB
67
#define BT_RTS_PIN              GPIO_Pin_13
68
#define BT_CTS_GPIO             GPIOB
69
#define BT_CTS_PIN              GPIO_Pin_14
70
#define SYS_UART_UP_GPIO        GPIOB
71
#define SYS_UART_UP_PIN         GPIO_Pin_15
72

  
73
#define CHARGE_STAT1A_GPIO      GPIOC
74
#define CHARGE_STAT1A_PIN       GPIO_Pin_0
75
#define GAUGE_BATLOW1_GPIO      GPIOC
76
#define GAUGE_BATLOW1_PIN       GPIO_Pin_1
77
#define GAUGE_BATGD1_N_GPIO     GPIOC
78
#define GAUGE_BATGD1_N_PIN      GPIO_Pin_2
79
#define CHARGE_EN1_N_GPIO       GPIOC
80
#define CHARGE_EN1_N_PIN        GPIO_Pin_3
81
#define IR_INT2_N_GPIO          GPIOC
82
#define IR_INT2_N_PIN           GPIO_Pin_4
83
#define TOUCH_INT_N_GPIO        GPIOC
84
#define TOUCH_INT_N_PIN         GPIO_Pin_5
85
#define SYS_DONE_GPIO           GPIOC
86
#define SYS_DONE_PIN            GPIO_Pin_6
87
#define SYS_PROG_N_GPIO         GPIOC
88
#define SYS_PROG_N_PIN          GPIO_Pin_7
89
#define PATH_DC_GPIO            GPIOC
90
#define PATH_DC_PIN             GPIO_Pin_8
91
#define SYS_SPI_DIR_GPIO        GPIOC
92
#define SYS_SPI_DIR_PIN         GPIO_Pin_9
93
#define BT_RX_GPIO              GPIOC
94
#define BT_RX_PIN               GPIO_Pin_10
95
#define BT_TX_GPIO              GPIOC
96
#define BT_TX_PIN               GPIO_Pin_11
97
#define SYS_SYNC_N_GPIO         GPIOC
98
#define SYS_SYNC_N_PIN          GPIO_Pin_12
99
#define SYS_PD_N_GPIO           GPIOC
100
#define SYS_PD_N_PIN            GPIO_Pin_13
101
#define SYS_WARMRST_N_GPIO      GPIOC
102
#define SYS_WARMRST_N_PIN       GPIO_Pin_14
103
#define BT_RST_GPIO             GPIOC
104
#define BT_RST_PIN              GPIO_Pin_15
105

  
106
#define OSC_IN_GPIO             GPIOD
107
#define OSC_IN_PIN              GPIO_Pin_0
108
#define OSC_OUT_GPIO            GPIOD
109
#define OSC_OUT_PIN             GPIO_Pin_1
110
#define CHARGE_EN2_N_GPIO       GPIOD
111
#define CHARGE_EN2_N_PIN        GPIO_Pin_2
112

  
113
#endif /* IODEF_H */
114

  
Target/Modules/PowerManagement_1-2/Boot/lib/ethernetlib/inc/stm32_eth.h
1
/**
2
  ******************************************************************************
3
  * @file    stm32_eth.h
4
  * @author  MCD Application Team
5
  * @version V1.0.0
6
  * @date    06/19/2009
7
  * @brief   This file contains all the functions prototypes for the Ethernet
8
  *          firmware library.
9
  ******************************************************************************
10
  * @copy
11
  *
12
  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
13
  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
14
  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
15
  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
16
  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
17
  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
18
  *
19
  * <h2><center>&copy; COPYRIGHT 2009 STMicroelectronics</center></h2>
20
  */ 
21

  
22
/* Define to prevent recursive inclusion -------------------------------------*/
23
#ifndef __STM32_ETH_H
24
#define __STM32_ETH_H
25

  
26
#ifdef __cplusplus
27
 extern "C" {
28
#endif
29

  
30
/* Includes ------------------------------------------------------------------*/
31
#include "stm32f4xx.h"                               /* STM32 registers                */
32

  
33
/** @addtogroup STM32_ETH_Driver
34
  * @{
35
  */
36

  
37
/** @defgroup ETH_Exported_Types
38
  * @{
39
  */
40

  
41
/** 
42
  * @brief  ETH MAC Init structure definition
43
  */ 
44
typedef struct {
45
/** 
46
  * @brief / * MAC  
47
  */ 
48
  uint32_t             ETH_AutoNegotiation;           /*!< Selects or not the AutoNegotiation with the external PHY */  
49
  uint32_t             ETH_Watchdog;                  /*!< Enable/disable Watchdog timer */  
50
  uint32_t             ETH_Jabber;                    /*!< Enable/disable Jabber timer */ 
51
  uint32_t             ETH_InterFrameGap;             /*!< Selects minimum IFG between frames during transmission */   
52
  uint32_t             ETH_CarrierSense;              /*!< Enable/disable Carrier Sense */ 
53
  uint32_t             ETH_Speed;                     /*!< Indicates the Ethernet speed: 10/100 Mbps */  
54
  uint32_t             ETH_ReceiveOwn;                /*!< Enable/disable the reception of frames when the TX_EN signal is asserted in Half-Duplex mode */  
55
  uint32_t             ETH_LoopbackMode;              /*!< Enable/disable internal MAC MII Loopback mode */ 
56
  uint32_t             ETH_Mode;                      /*!< Selects the MAC duplex mode: Half-Duplex or Full-Duplex mode */ 
57
  uint32_t             ETH_ChecksumOffload;           /*!< Enable/disable the calculation of complement sum of all received Ethernet frame payloads */   
58
  uint32_t             ETH_RetryTransmission;         /*!< Enable/disable the MAC attempt retries transmission, based on the settings of BL, when a colision occurs (Half-Duplex mode) */
59
  uint32_t             ETH_AutomaticPadCRCStrip;      /*!< Enable/disable Automatic MAC Pad/CRC Stripping */ 
60
  uint32_t             ETH_BackOffLimit;              /*!< Selects the BackOff limit value */ 
61
  uint32_t             ETH_DeferralCheck;             /*!< Enable/disable deferral check function (Half-Duplex mode) */                                                                                                       
62
  uint32_t             ETH_ReceiveAll;                /*!< Enable/disable all frames reception by the MAC (No fitering)*/ 
63
  uint32_t             ETH_SourceAddrFilter;          /*!< Selects EnableNormal/EnableInverse/disable Source Address Filter comparison */                  
64
  uint32_t             ETH_PassControlFrames;         /*!< Selects None/All/FilterPass of all control frames (including unicast and multicast PAUSE frames) */ 
65
  uint32_t             ETH_BroadcastFramesReception;  /*!< Enable/disable reception of Broadcast Frames */
66
  uint32_t             ETH_DestinationAddrFilter;     /*!< Selects EnableNormal/EnableInverse destination filter for both unicast and multicast frames */ 
67
  uint32_t             ETH_PromiscuousMode;           /*!< Enable/disable Promiscuous Mode */
68
  uint32_t             ETH_MulticastFramesFilter;     /*!< Selects the Multicast Frames filter: None/HashTableFilter/PerfectFilter/PerfectHashTableFilter */ 
69
  uint32_t             ETH_UnicastFramesFilter;       /*!< Selects the Unicast Frames filter: HashTableFilter/PerfectFilter/PerfectHashTableFilter  */
70
  uint32_t             ETH_HashTableHigh;             /*!< This field contains the higher 32 bits of Hash table.  */    
71
  uint32_t             ETH_HashTableLow;              /*!< This field contains the lower 32 bits of Hash table.  */    
72
  uint32_t             ETH_PauseTime;                 /*!< This field holds the value to be used in the Pause Time field in the transmit control frame */
73
  uint32_t             ETH_ZeroQuantaPause;           /*!< Enable/disable the automatic generation of Zero-Quanta Pause Control frames */ 
74
  uint32_t             ETH_PauseLowThreshold;         /*!< This field configures the threshold of the PAUSE to be checked for automatic retransmission of PAUSE Frame */
75
  uint32_t             ETH_UnicastPauseFrameDetect;   /*!< Enable/disable MAC to detect the Pause frames (with MAC Address0 unicast address and unique multicast address) */ 
76
  uint32_t             ETH_ReceiveFlowControl;        /*!< Enable/disable the MAC to decode the received Pause frame and disable its transmitter for a specified (Pause Time) time */
77
  uint32_t             ETH_TransmitFlowControl;       /*!< Enable/disable the MAC to transmit Pause frames (Full-Duplex mode) or the MAC back-pressure operation (Half-Duplex mode) */     
78
  uint32_t             ETH_VLANTagComparison;         /*!< Selects the 12-bit VLAN identifier or the complete 16-bit VLAN tag for comparison and filtering */ 
79
  uint32_t             ETH_VLANTagIdentifier;         /*!< VLAN tag identifier for receive frames */
80

  
81
/** 
82
  * @brief / * DMA  
83
  */ 
84
  uint32_t             ETH_DropTCPIPChecksumErrorFrame; /*!< Enable/disable Dropping of TCP/IP Checksum Error Frames */
85
  uint32_t             ETH_ReceiveStoreForward;         /*!< Enable/disable Receive store and forward */
86
  uint32_t             ETH_FlushReceivedFrame;          /*!< Enable/disable flushing of received frames */
87
  uint32_t             ETH_TransmitStoreForward;        /*!< Enable/disable Transmit store and forward */
88
  uint32_t             ETH_TransmitThresholdControl;    /*!< Selects the Transmit Threshold Control */
89
  uint32_t             ETH_ForwardErrorFrames;          /*!< Enable/disable forward to DMA of all frames except runt error frames */
90
  uint32_t             ETH_ForwardUndersizedGoodFrames; /*!< Enable/disable Rx FIFO to forward Undersized frames (frames with no Error and length less than 64 bytes) including pad-bytes and CRC) */
91
  uint32_t             ETH_ReceiveThresholdControl;     /*!< Selects the threshold level of the Receive FIFO */
92
  uint32_t             ETH_SecondFrameOperate;          /*!< Enable/disable the DMA process of a second frame of Transmit data even before status for first frame is obtained */
93
  uint32_t             ETH_AddressAlignedBeats;         /*!< Enable/disable Address Aligned Beats */
94
  uint32_t             ETH_FixedBurst;                  /*!< Enable/disable the AHB Master interface fixed burst transfers */
95
  uint32_t             ETH_RxDMABurstLength;            /*!< Indicate the maximum number of beats to be transferred in one Rx DMA transaction */
96
  uint32_t             ETH_TxDMABurstLength;            /*!< Indicate the maximum number of beats to be transferred in one Tx DMA transaction */                                                 
97
  uint32_t             ETH_DescriptorSkipLength;        /*!< Specifies the number of word to skip between two unchained descriptors (Ring mode) */
98
  uint32_t             ETH_DMAArbitration;              /*!< Selects DMA Tx/Rx arbitration */  
99
}ETH_InitTypeDef;
100

  
101
/**--------------------------------------------------------------------------**/
102
/** 
103
  * @brief                           DMA descriptors types
104
  */ 
105
/**--------------------------------------------------------------------------**/
106

  
107
/** 
108
  * @brief  ETH DMA Desciptors data structure definition
109
  */ 
110
typedef struct  {
111
  uint32_t   Status;                /*!< Status */
112
  uint32_t   ControlBufferSize;     /*!< Control and Buffer1, Buffer2 lengths */
113
  uint32_t   Buffer1Addr;           /*!< Buffer1 address pointer */
114
  uint32_t   Buffer2NextDescAddr;   /*!< Buffer2 or next descriptor address pointer */
115
} ETH_DMADESCTypeDef;
116

  
117
/**
118
  * @}
119
  */
120

  
121
/** @defgroup ETH_Exported_Constants
122
  * @{
123
  */ 
124
/**--------------------------------------------------------------------------**/
125
/** 
126
  * @brief                          ETH Frames defines
127
  */ 
128
/**--------------------------------------------------------------------------**/
129

  
130
/** @defgroup ENET_Buffers_setting 
131
  * @{
132
  */ 
133
#define ETH_MAX_PACKET_SIZE    1520    /*!< ETH_HEADER + ETH_EXTRA + MAX_ETH_PAYLOAD + ETH_CRC */
134
#define ETH_HEADER               14    /*!< 6 byte Dest addr, 6 byte Src addr, 2 byte length/type */
135
#define ETH_CRC                   4    /*!< Ethernet CRC */
136
#define ETH_EXTRA                 2    /*!< Extra bytes in some cases */   
137
#define VLAN_TAG                  4    /*!< optional 802.1q VLAN Tag */
138
#define MIN_ETH_PAYLOAD          46    /*!< Minimum Ethernet payload size */
139
#define MAX_ETH_PAYLOAD        1500    /*!< Maximum Ethernet payload size */
140
#define JUMBO_FRAME_PAYLOAD    9000    /*!< Jumbo frame payload size */      
141

  
142
/**--------------------------------------------------------------------------**/
143
/** 
144
  * @brief                 Ethernet DMA descriptors registers bits definition
145
  */ 
146
/**--------------------------------------------------------------------------**/
147

  
148
/* DMA Tx Desciptor -----------------------------------------------------------*/
149
/**----------------------------------------------------------------------------------------------
150
  TDES0 | OWN(31) | CTRL[30:26] | Reserved[25:24] | CTRL[23:20] | Reserved[19:17] | Status[16:0] |
151
  -----------------------------------------------------------------------------------------------
152
  TDES1 | Reserved[31:29] | Buffer2 ByteCount[28:16] | Reserved[15:13] | Buffer1 ByteCount[12:0] |
153
  -----------------------------------------------------------------------------------------------
154
  TDES2 |                         Buffer1 Address [31:0]                                         |
155
  -----------------------------------------------------------------------------------------------
156
  TDES3 |                   Buffer2 Address [31:0] / Next Desciptor Address [31:0]               |
157
  ---------------------------------------------------------------------------------------------**/
158

  
159
/** 
160
  * @brief  Bit definition of TDES0 register: DMA Tx descriptor status register
161
  */ 
162
#define ETH_DMATxDesc_OWN                     ((uint32_t)0x80000000)  /*!< OWN bit: descriptor is owned by DMA engine */
163
#define ETH_DMATxDesc_IC                      ((uint32_t)0x40000000)  /*!< Interrupt on Completion */
164
#define ETH_DMATxDesc_LS                      ((uint32_t)0x20000000)  /*!< Last Segment */
165
#define ETH_DMATxDesc_FS                      ((uint32_t)0x10000000)  /*!< First Segment */
166
#define ETH_DMATxDesc_DC                      ((uint32_t)0x08000000)  /*!< Disable CRC */
167
#define ETH_DMATxDesc_DP                      ((uint32_t)0x04000000)  /*!< Disable Padding */
168
#define ETH_DMATxDesc_TTSE                    ((uint32_t)0x02000000)  /*!< Transmit Time Stamp Enable */
169
#define ETH_DMATxDesc_CIC                     ((uint32_t)0x00C00000)  /*!< Checksum Insertion Control: 4 cases */
170
#define ETH_DMATxDesc_CIC_ByPass              ((uint32_t)0x00000000)  /*!< Do Nothing: Checksum Engine is bypassed */ 
171
#define ETH_DMATxDesc_CIC_IPV4Header          ((uint32_t)0x00400000)  /*!< IPV4 header Checksum Insertion */ 
172
#define ETH_DMATxDesc_CIC_TCPUDPICMP_Segment  ((uint32_t)0x00800000)  /*!< TCP/UDP/ICMP Checksum Insertion calculated over segment only */ 
173
#define ETH_DMATxDesc_CIC_TCPUDPICMP_Full     ((uint32_t)0x00C00000)  /*!< TCP/UDP/ICMP Checksum Insertion fully calculated */ 
174
#define ETH_DMATxDesc_TER                     ((uint32_t)0x00200000)  /*!< Transmit End of Ring */
175
#define ETH_DMATxDesc_TCH                     ((uint32_t)0x00100000)  /*!< Second Address Chained */
176
#define ETH_DMATxDesc_TTSS                    ((uint32_t)0x00020000)  /*!< Tx Time Stamp Status */
177
#define ETH_DMATxDesc_IHE                     ((uint32_t)0x00010000)  /*!< IP Header Error */
178
#define ETH_DMATxDesc_ES                      ((uint32_t)0x00008000)  /*!< Error summary: OR of the following bits: UE || ED || EC || LCO || NC || LCA || FF || JT */
179
#define ETH_DMATxDesc_JT                      ((uint32_t)0x00004000)  /*!< Jabber Timeout */
180
#define ETH_DMATxDesc_FF                      ((uint32_t)0x00002000)  /*!< Frame Flushed: DMA/MTL flushed the frame due to SW flush */
181
#define ETH_DMATxDesc_PCE                     ((uint32_t)0x00001000)  /*!< Payload Checksum Error */
182
#define ETH_DMATxDesc_LCA                     ((uint32_t)0x00000800)  /*!< Loss of Carrier: carrier lost during tramsmission */
183
#define ETH_DMATxDesc_NC                      ((uint32_t)0x00000400)  /*!< No Carrier: no carrier signal from the tranceiver */
184
#define ETH_DMATxDesc_LCO                     ((uint32_t)0x00000200)  /*!< Late Collision: transmission aborted due to collision */
185
#define ETH_DMATxDesc_EC                      ((uint32_t)0x00000100)  /*!< Excessive Collision: transmission aborted after 16 collisions */
186
#define ETH_DMATxDesc_VF                      ((uint32_t)0x00000080)  /*!< VLAN Frame */
187
#define ETH_DMATxDesc_CC                      ((uint32_t)0x00000078)  /*!< Collision Count */
188
#define ETH_DMATxDesc_ED                      ((uint32_t)0x00000004)  /*!< Excessive Deferral */
189
#define ETH_DMATxDesc_UF                      ((uint32_t)0x00000002)  /*!< Underflow Error: late data arrival from the memory */
190
#define ETH_DMATxDesc_DB                      ((uint32_t)0x00000001)  /*!< Deferred Bit */
191

  
192
/** 
193
  * @brief  Bit definition of TDES1 register
194
  */ 
195
#define ETH_DMATxDesc_TBS2  ((uint32_t)0x1FFF0000)  /*!< Transmit Buffer2 Size */
196
#define ETH_DMATxDesc_TBS1  ((uint32_t)0x00001FFF)  /*!< Transmit Buffer1 Size */
197

  
198
/** 
199
  * @brief  Bit definition of TDES2 register
200
  */ 
201
#define ETH_DMATxDesc_B1AP  ((uint32_t)0xFFFFFFFF)  /*!< Buffer1 Address Pointer */
202

  
203
/** 
204
  * @brief  Bit definition of TDES3 register
205
  */ 
206
#define ETH_DMATxDesc_B2AP  ((uint32_t)0xFFFFFFFF)  /*!< Buffer2 Address Pointer */
207

  
208
/**
209
  * @}
210
  */ 
211

  
212

  
213
/** @defgroup DMA_Rx_descriptor 
214
  * @{
215
  */
216

  
217
/**--------------------------------------------------------------------------------------------------------------------
218
  RDES0 | OWN(31) |                                             Status [30:0]                                          |
219
  ---------------------------------------------------------------------------------------------------------------------
220
  RDES1 | CTRL(31) | Reserved[30:29] | Buffer2 ByteCount[28:16] | CTRL[15:14] | Reserved(13) | Buffer1 ByteCount[12:0] |
221
  ---------------------------------------------------------------------------------------------------------------------
222
  RDES2 |                                       Buffer1 Address [31:0]                                                 |
223
  ---------------------------------------------------------------------------------------------------------------------
224
  RDES3 |                          Buffer2 Address [31:0] / Next Desciptor Address [31:0]                              |
225
  -------------------------------------------------------------------------------------------------------------------**/
226

  
227
/** 
228
  * @brief  Bit definition of RDES0 register: DMA Rx descriptor status register
229
  */ 
230
#define ETH_DMARxDesc_OWN         ((uint32_t)0x80000000)  /*!< OWN bit: descriptor is owned by DMA engine  */
231
#define ETH_DMARxDesc_AFM         ((uint32_t)0x40000000)  /*!< DA Filter Fail for the rx frame  */
232
#define ETH_DMARxDesc_FL          ((uint32_t)0x3FFF0000)  /*!< Receive descriptor frame length  */
233
#define ETH_DMARxDesc_ES          ((uint32_t)0x00008000)  /*!< Error summary: OR of the following bits: DE || OE || IPC || LC || RWT || RE || CE */
234
#define ETH_DMARxDesc_DE          ((uint32_t)0x00004000)  /*!< Desciptor error: no more descriptors for receive frame  */
235
#define ETH_DMARxDesc_SAF         ((uint32_t)0x00002000)  /*!< SA Filter Fail for the received frame */
236
#define ETH_DMARxDesc_LE          ((uint32_t)0x00001000)  /*!< Frame size not matching with length field */
237
#define ETH_DMARxDesc_OE          ((uint32_t)0x00000800)  /*!< Overflow Error: Frame was damaged due to buffer overflow */
238
#define ETH_DMARxDesc_VLAN        ((uint32_t)0x00000400)  /*!< VLAN Tag: received frame is a VLAN frame */
239
#define ETH_DMARxDesc_FS          ((uint32_t)0x00000200)  /*!< First descriptor of the frame  */
240
#define ETH_DMARxDesc_LS          ((uint32_t)0x00000100)  /*!< Last descriptor of the frame  */ 
241
#define ETH_DMARxDesc_IPV4HCE     ((uint32_t)0x00000080)  /*!< IPC Checksum Error: Rx Ipv4 header checksum error   */    
242
#define ETH_DMARxDesc_LC          ((uint32_t)0x00000040)  /*!< Late collision occurred during reception   */
243
#define ETH_DMARxDesc_FT          ((uint32_t)0x00000020)  /*!< Frame type - Ethernet, otherwise 802.3    */
244
#define ETH_DMARxDesc_RWT         ((uint32_t)0x00000010)  /*!< Receive Watchdog Timeout: watchdog timer expired during reception    */
245
#define ETH_DMARxDesc_RE          ((uint32_t)0x00000008)  /*!< Receive error: error reported by MII interface  */
246
#define ETH_DMARxDesc_DBE         ((uint32_t)0x00000004)  /*!< Dribble bit error: frame contains non int multiple of 8 bits  */
247
#define ETH_DMARxDesc_CE          ((uint32_t)0x00000002)  /*!< CRC error */
248
#define ETH_DMARxDesc_MAMPCE      ((uint32_t)0x00000001)  /*!< Rx MAC Address/Payload Checksum Error: Rx MAC address matched/ Rx Payload Checksum Error */
249

  
250
/** 
251
  * @brief  Bit definition of RDES1 register
252
  */ 
253
#define ETH_DMARxDesc_DIC   ((uint32_t)0x80000000)  /*!< Disable Interrupt on Completion */
254
#define ETH_DMARxDesc_RBS2  ((uint32_t)0x1FFF0000)  /*!< Receive Buffer2 Size */
255
#define ETH_DMARxDesc_RER   ((uint32_t)0x00008000)  /*!< Receive End of Ring */
256
#define ETH_DMARxDesc_RCH   ((uint32_t)0x00004000)  /*!< Second Address Chained */
257
#define ETH_DMARxDesc_RBS1  ((uint32_t)0x00001FFF)  /*!< Receive Buffer1 Size */
258

  
259
/** 
260
  * @brief  Bit definition of RDES2 register  
261
  */ 
262
#define ETH_DMARxDesc_B1AP  ((uint32_t)0xFFFFFFFF)  /*!< Buffer1 Address Pointer */
263

  
264
/** 
265
  * @brief  Bit definition of RDES3 register  
266
  */ 
267
#define ETH_DMARxDesc_B2AP  ((uint32_t)0xFFFFFFFF)  /*!< Buffer2 Address Pointer */
268

  
269
/**--------------------------------------------------------------------------**/
270
/** 
271
  * @brief                     Desciption of common PHY registers
272
  */ 
273
/**--------------------------------------------------------------------------**/
274

  
275
/**
276
  * @}
277
  */
278

  
279
/** @defgroup PHY_Read_write_Timeouts 
280
  * @{
281
  */ 
282
#define PHY_READ_TO                     ((uint32_t)0x0004FFFF)
283
#define PHY_WRITE_TO                    ((uint32_t)0x0004FFFF)
284

  
285
/**
286
  * @}
287
  */
288

  
289
/** @defgroup PHY_Reset_Delay 
290
  * @{
291
  */ 
292
#define PHY_ResetDelay                  ((uint32_t)0x04000000) 
293

  
294
/**
295
  * @}
296
  */
297

  
298
/** @defgroup PHY_Config_Delay 
299
  * @{
300
  */ 
301
#define PHY_ConfigDelay                 ((uint32_t)0x00FFFFFF)
302

  
303
/**
304
  * @}
305
  */
306

  
307
/** @defgroup PHY_Register_address 
308
  * @{
309
  */ 
310
#define PHY_BCR                          0          /*!< Tranceiver Basic Control Register */
311
#define PHY_BSR                          1          /*!< Tranceiver Basic Status Register */
312

  
313
/**
314
  * @}
315
  */
316

  
317
/** @defgroup PHY_basic_Control_register 
318
  * @{
319
  */ 
320
#define PHY_Reset                       ((u16)0x8000)      /*!< PHY Reset */
321
#define PHY_Loopback                    ((u16)0x4000)      /*!< Select loop-back mode */
322
#define PHY_FULLDUPLEX_100M             ((u16)0x2100)      /*!< Set the full-duplex mode at 100 Mb/s */
323
#define PHY_HALFDUPLEX_100M             ((u16)0x2000)      /*!< Set the half-duplex mode at 100 Mb/s */
324
#define PHY_FULLDUPLEX_10M              ((u16)0x0100)      /*!< Set the full-duplex mode at 10 Mb/s */
325
#define PHY_HALFDUPLEX_10M              ((u16)0x0000)      /*!< Set the half-duplex mode at 10 Mb/s */
326
#define PHY_AutoNegotiation             ((u16)0x1000)      /*!< Enable auto-negotiation function */
327
#define PHY_Restart_AutoNegotiation     ((u16)0x0200)      /*!< Restart auto-negotiation function */
328
#define PHY_Powerdown                   ((u16)0x0800)      /*!< Select the power down mode */
329
#define PHY_Isolate                     ((u16)0x0400)      /*!< Isolate PHY from MII */
330

  
331
/**
332
  * @}
333
  */
334

  
335
/** @defgroup PHY_basic_status_register 
336
  * @{
337
  */ 
338
#define PHY_AutoNego_Complete           ((u16)0x0020)      /*!< Auto-Negotioation process completed */
339
#define PHY_Linked_Status               ((u16)0x0004)      /*!< Valid link established */
340
#define PHY_Jabber_detection            ((u16)0x0002)      /*!< Jabber condition detected */
341

  
342
/**
343
  * @}
344
  */
345

  
346
/** @defgroup PHY_status_register 
347
  * @{
348
  */ 
349
/* The PHY status register value change from a PHY to another so the user have 
350
   to update this value depending on the used external PHY */
351
/** 
352
  * @brief  For LAN8700  
353
  */ 
354
//#define PHY_SR                           31         /*!< Tranceiver Status Register */
355
/** 
356
  * @brief  For DP83848  
357
  */ 
358
#define PHY_SR                           16     /*!< Tranceiver Status Register */
359

  
360
/* The Speed and Duplex mask values change from a PHY to another so the user have to update
361
   this value depending on the used external PHY */
362
/** 
363
  * @brief  For LAN8700  
364
  */ 
365
//#define PHY_Speed_Status            ((u16)0x0004)       /*!< Configured information of Speed: 10Mbps */
366
//#define PHY_Duplex_Status           ((u16)0x0010)       /*!< Configured information of Duplex: Full-duplex */
367

  
368
/** 
369
  * @brief  For DP83848  
370
  */ 
371
#define PHY_Speed_Status            ((u16)0x0002)    /*!< Configured information of Speed: 10Mbps */
372
#define PHY_Duplex_Status           ((u16)0x0004)    /*!< Configured information of Duplex: Full-duplex */
373
#define IS_ETH_PHY_ADDRESS(ADDRESS) ((ADDRESS) <= 0x20)
374
#define IS_ETH_PHY_REG(REG) (((REG) == PHY_BCR) || \
375
                             ((REG) == PHY_BSR) || \
376
                             ((REG) == PHY_SR))
377

  
378
/**--------------------------------------------------------------------------**/
379
/** 
380
  * @brief                                  MAC defines
381
  */ 
382
/**--------------------------------------------------------------------------**/
383

  
384
/**
385
  * @}
386
  */ 
387

  
388
/** @defgroup ETH_AutoNegotiation 
389
  * @{
390
  */ 
391
#define ETH_AutoNegotiation_Enable     ((uint32_t)0x00000001)
392
#define ETH_AutoNegotiation_Disable    ((uint32_t)0x00000000)
393
#define IS_ETH_AUTONEGOTIATION(CMD) (((CMD) == ETH_AutoNegotiation_Enable) || \
394
                                     ((CMD) == ETH_AutoNegotiation_Disable))
395

  
396
/**
397
  * @}
398
  */
399

  
400
/** @defgroup ETH_watchdog 
401
  * @{
402
  */ 
403
#define ETH_Watchdog_Enable       ((uint32_t)0x00000000)
404
#define ETH_Watchdog_Disable      ((uint32_t)0x00800000)
405
#define IS_ETH_WATCHDOG(CMD) (((CMD) == ETH_Watchdog_Enable) || \
406
                              ((CMD) == ETH_Watchdog_Disable))
407

  
408
/**
409
  * @}
410
  */
411

  
412
/** @defgroup ETH_Jabber 
413
  * @{
414
  */ 
415
#define ETH_Jabber_Enable    ((uint32_t)0x00000000)
416
#define ETH_Jabber_Disable   ((uint32_t)0x00400000)
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff