Embedded TCP/IP stack: fnet_cpu.h Source File

FNET

fnet_cpu.h
1 /**************************************************************************
2 *
3 * Copyright 2011-2017 by Andrey Butok. FNET Community.
4 * Copyright 2008-2010 by Andrey Butok. Freescale Semiconductor, Inc.
5 *
6 ***************************************************************************
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 * not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 ***************************************************************************
21 *
22 * CPU-specific library API.
23 *
24 ***************************************************************************/
25 
26 #ifndef _FNET_CPU_H_
27 
28 #define _FNET_CPU_H_
29 
30 #include "fnet_config.h"
31 
32 #if FNET_MCF /* ColdFire.*/
33  #include "mcf/fnet_mcf.h"
34 #endif
35 
36 #if FNET_MK /* Kinetis.*/
37  #include "mk/fnet_mk.h"
38 #endif
39 
40 #if FNET_MPC /* MPC.*/
41  #include "mpc/fnet_mpc.h"
42 #endif
43 
44 #if FNET_LPC /* NXP's LPC.*/
45  #include "lpc/fnet_lpc.h"
46 #endif
47 
48 #include "stack/fnet_stdlib.h"
49 
53 #if defined(__cplusplus)
54 extern "C" {
55 #endif
56 
57 /************************************************************************
58 * For doing byte order conversions between CPU
59 * and the independent "network" order.
60 * For Freescale CPUs they just return the variable passed.
61 *************************************************************************/
62 
63 #if FNET_CFG_CPU_LITTLE_ENDIAN /* Little endian.*/ || defined(__DOXYGEN__)
64 
65 /**************************************************************************/
73 #define FNET_HTONS(short_var) ((((short_var) & 0x00FFU) << 8U) | (((short_var) & 0xFF00U) >> 8U))
74 /**************************************************************************/
82 #define FNET_NTOHS(short_var) FNET_HTONS(short_var)
83 /**************************************************************************/
91 #define FNET_HTONL(long_var) ((((long_var) & 0x000000FFU) << 24U) | (((long_var) & 0x0000FF00U) << 8U) | (((long_var) & 0x00FF0000U) >> 8U) | (((long_var) & 0xFF000000U) >> 24U))
92 /**************************************************************************/
100 #define FNET_NTOHL(long_var) FNET_HTONL(long_var)
101 
102 /***************************************************************************/
120 fnet_uint16_t fnet_htons(fnet_uint16_t short_var);
121 
122 #define fnet_ntohs fnet_htons
123 /***************************************************************************/
141 fnet_uint16_t fnet_ntohs(fnet_uint16_t short_var);
142 
143 /***************************************************************************/
161 fnet_uint32_t fnet_htonl(fnet_uint32_t long_var);
162 
163 #define fnet_ntohl fnet_htonl
164 /***************************************************************************/
182 fnet_uint32_t fnet_ntohl(fnet_uint32_t long_var);
183 
184 
185 #else /* Big endian. */
186 #define FNET_HTONS(short_var) (short_var)
187 #define FNET_NTOHS(short_var) (short_var)
188 #define FNET_HTONL(long_var) (long_var)
189 #define FNET_NTOHL(long_var) (long_var)
190 
191 #define fnet_htons(short_var) (short_var) /* Convert 16 bit integer from host- to network byte order.*/
192 #define fnet_ntohs(short_var) (short_var) /* Convert 16 bit integer from network - to host byte order.*/
193 #define fnet_htonl(long_var) (long_var) /* Convert 32 bit integer from host- to network byte order.*/
194 #define fnet_ntohl(long_var) (long_var) /* Convert 32 bit integer from network - to host byte order.*/
195 #endif
196 
206 /**************************************************************************/
211 typedef fnet_uint32_t fnet_cpu_irq_desc_t;
212 
213 /***************************************************************************/
223 void fnet_cpu_reset (void);
224 
225 /***************************************************************************/
240 fnet_cpu_irq_desc_t fnet_cpu_irq_disable(void);
241 
242 /***************************************************************************/
259 void fnet_cpu_irq_enable(fnet_cpu_irq_desc_t irq_desc);
260 
261 /***************************************************************************/
277 void fnet_cpu_serial_putchar( fnet_index_t port_number, fnet_char_t character );
278 
279 /***************************************************************************/
297 fnet_int32_t fnet_cpu_serial_getchar( fnet_index_t port_number );
298 
299 /***************************************************************************/
315 void fnet_cpu_serial_init(fnet_index_t port_number, fnet_uint32_t baud_rate);
316 
317 /***************************************************************************/
327 #if FNET_CFG_CPU_CACHE || defined(__DOXYGEN__)
328 void fnet_cpu_cache_invalidate(void);
329 #else
330 #define fnet_cpu_cache_invalidate() do{}while(0)
331 #endif
332 
333 /***************************************************************************/
360 
361 /***************************************************************************/
383 fnet_return_t fnet_cpu_flash_write(fnet_uint8_t *dest, const fnet_uint8_t *data);
384 
385 /***************************************************************************/
396 void fnet_cpu_isr(void);
397 
398 /***************************************************************************/
414 #ifndef FNET_CPU_ADDR_TO_INSTRUCTION
415 #define FNET_CPU_ADDR_TO_INSTRUCTION(addr) (addr)
416 #endif
417 
418 /***************************************************************************/
434 #ifndef FNET_CPU_INSTRUCTION_TO_ADDR
435 #define FNET_CPU_INSTRUCTION_TO_ADDR(addr) (addr)
436 #endif
437 
438 struct fnet_netif; /* Forward declaration.*/
439 #if FNET_CFG_CPU_ETH0
440 extern struct fnet_netif fnet_cpu_eth0_if;
441 #define FNET_CPU_ETH0_IF ((fnet_netif_desc_t)(&fnet_cpu_eth0_if))
442 #endif
443 #if FNET_CFG_CPU_ETH1
444 extern struct fnet_netif fnet_cpu_eth1_if;
445 #define FNET_CPU_ETH1_IF ((fnet_netif_desc_t)(&fnet_cpu_eth1_if))
446 #endif
447 #if FNET_CFG_CPU_WIFI
448 extern struct fnet_netif fnet_cpu_wifi_if;
449 #define FNET_CPU_WIFI_IF ((fnet_netif_desc_t)(&fnet_cpu_wifi_if))
450 #endif
451 
452 /***************************************************************************/
456 #define FNET_CPU_NETIF_NUMBER (FNET_CFG_CPU_ETH0+FNET_CFG_CPU_ETH1+FNET_CFG_CPU_WIFI)
457 
458 #if defined(__cplusplus)
459 }
460 #endif
461 
464 #endif /* _FNET_CPU_H_ */
void fnet_cpu_cache_invalidate(void)
Invalidates CPU-cache memory.
fnet_uint16_t fnet_ntohs(fnet_uint16_t short_var)
Converts 16-bit value from network to host byte order.
void fnet_cpu_irq_enable(fnet_cpu_irq_desc_t irq_desc)
Enables interrupts.
fnet_int32_t fnet_cpu_serial_getchar(fnet_index_t port_number)
Reads character from the serial port.
void fnet_cpu_serial_putchar(fnet_index_t port_number, fnet_char_t character)
Writes character to the serial port.
fnet_return_t
General return codes, used by most of API functions.
Definition: fnet_stdlib.h:90
unsigned long fnet_size_t
Unsigned integer type representing the size in bytes.
Definition: fnet_stdlib.h:56
void fnet_cpu_serial_init(fnet_index_t port_number, fnet_uint32_t baud_rate)
Initializes the serial port.
fnet_uint16_t fnet_htons(fnet_uint16_t short_var)
Converts 16-bit value from host to network byte order.
fnet_uint32_t fnet_htonl(fnet_uint32_t long_var)
Converts 32-bit value from host to network byte order.
fnet_return_t fnet_cpu_flash_write(fnet_uint8_t *dest, const fnet_uint8_t *data)
Writes the specified data to the Flash memory.
fnet_size_t bytes
Number of received bytes, in addition to megabytes, during the benchmark session. ...
fnet_uint32_t fnet_cpu_irq_desc_t
IRQ status descriptor returned by the fnet_cpu_irq_disable() function. Actually it corresponds to the...
Definition: fnet_cpu.h:211
fnet_return_t fnet_cpu_flash_erase(void *flash_addr, fnet_size_t bytes)
Erases the specified range of the Flash memory.
void fnet_cpu_isr(void)
CPU-specific FNET interrupt service routine.
fnet_cpu_irq_desc_t fnet_cpu_irq_disable(void)
Disables all interrupts.
void fnet_cpu_reset(void)
Initiates software reset.
unsigned int fnet_index_t
Unsigned integer type representing the index.
Definition: fnet_stdlib.h:71
char fnet_char_t
Type representing the charecter.
Definition: fnet_stdlib.h:76
fnet_uint32_t fnet_ntohl(fnet_uint32_t long_var)
Converts 32-bit value from network to host byte order.

© 2005-2018 by Andrey Butok. http://fnet.sourceforge.net