aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-09-25 10:38:58 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-09-25 10:38:58 +0000
commitdf471c97569f94d75efcdd00d19274bab243c981 (patch)
tree6fd7aaf635ed18f73f82992cbde409313dd09c22
parentd107ffedee36864fc238e791bddb02320a7bb30e (diff)
downloadChibiOS-df471c97569f94d75efcdd00d19274bab243c981.tar.gz
ChibiOS-df471c97569f94d75efcdd00d19274bab243c981.tar.bz2
ChibiOS-df471c97569f94d75efcdd00d19274bab243c981.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1180 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--os/io/mac.c53
-rw-r--r--os/io/mac.h19
-rw-r--r--os/io/phy.c30
-rw-r--r--os/io/phy.h42
-rw-r--r--os/io/serial.h3
-rw-r--r--os/io/templates/mac_lld.c26
-rw-r--r--os/io/templates/mac_lld.h29
7 files changed, 161 insertions, 41 deletions
diff --git a/os/io/mac.c b/os/io/mac.c
index 16c55d644..823a1b4a7 100644
--- a/os/io/mac.c
+++ b/os/io/mac.c
@@ -50,23 +50,28 @@ void macInit(void) {
/**
* @brief MAC address setup.
- *
+ *
+ * @param[in] macp pointer to the @p MACDriver object
* @param[in] p pointer to a six bytes buffer containing the MAC address. If
* this parameter is set to @p NULL then a system default MAC is
* used.
*
- * @note This function should be invoked after the @p macInit() and before
- * @p macStart() else the result is unspecified (performed or ignored).
+ * @note This function must be invoked only with the driver in the stopped
+ * state. If invoked on an active interface then it is ignored.
*/
-void macSetAddress(uint8_t *p) {
+void macSetAddress(MACDriver *macp, uint8_t *p) {
- mac_lld_set_address(p);
+ if (state == ifStopped)
+ mac_lld_set_address(macp, p);
}
/**
- * @brief Startsthe I/O activity and enters a low power mode.
+ * @brief Startsthe I/O activity and enters a low power mode.
+ *
+ * @param[in] macp pointer to the @p MACDriver object
+ *
*/
-void macStart(void) {
+void macStart(MACDriver *macp) {
chSysLock();
if (state == ifStarted) {
@@ -75,13 +80,15 @@ void macStart(void) {
}
state = ifStarted;
chSysUnlock();
- mac_lld_start();
+ mac_lld_start(macp);
}
/**
- * @brief Stops the I/O activity.
+ * @brief Stops the I/O activity.
+ *
+ * @param[in] macp pointer to the @p MACDriver object
*/
-void macStop(void) {
+void macStop(MACDriver *macp) {
chSysLock();
if (state == ifStopped) {
@@ -93,7 +100,7 @@ void macStop(void) {
chSemResetI(&rdsem, 0);
chSchRescheduleS();
chSysUnlock();
- mac_lld_stop();
+ mac_lld_stop(macp);
}
/**
@@ -102,6 +109,7 @@ void macStop(void) {
* returned. If a descriptor is not currently available then the
* invoking thread is queued until one is freed.
*
+ * @param[in] macp pointer to the @p MACDriver object
* @param[in] time the number of ticks before the operation timeouts,
* the following special values are allowed:
* - @a TIME_IMMEDIATE immediate timeout.
@@ -110,7 +118,8 @@ void macStop(void) {
* @return A pointer to a @p MACTransmitDescriptor structure or @p NULL if
* the operation timed out or the driver went in stop mode.
*/
-MACTransmitDescriptor *macWaitTransmitDescriptor(systime_t time) {
+MACTransmitDescriptor *macWaitTransmitDescriptor(MACDriver *macp,
+ systime_t time) {
MACTransmitDescriptor *tdp;
chSysLock();
@@ -118,7 +127,7 @@ MACTransmitDescriptor *macWaitTransmitDescriptor(systime_t time) {
if ((state == ifStopped) || (chSemWaitTimeoutS(&tdsem, time) != RDY_OK))
tdp = NULL;
else
- tdp = max_lld_get_transmit_descriptor();
+ tdp = max_lld_get_transmit_descriptor(macp);
chSysUnlock();
return tdp;
@@ -128,12 +137,14 @@ MACTransmitDescriptor *macWaitTransmitDescriptor(systime_t time) {
* @brief Releases a transmit descriptor and starts the transmission of the
* enqueued data as a single frame.
*
+ * @param[in] macp pointer to the @p MACDriver object
* @param[in] tdp the pointer to the @p MACTransmitDescriptor structure
*/
-void macReleaseTransmitDescriptor(MACTransmitDescriptor *tdp) {
+void macReleaseTransmitDescriptor(MACDriver *macp,
+ MACTransmitDescriptor *tdp) {
if (state == ifStarted)
- mac_lld_release_transmit_descriptor(tdp);
+ mac_lld_release_transmit_descriptor(macp, tdp);
}
/**
@@ -142,6 +153,7 @@ void macReleaseTransmitDescriptor(MACTransmitDescriptor *tdp) {
* not immediately available then the invoking thread is queued
* until one is received.
*
+ * @param[in] macp pointer to the @p MACDriver object
* @param[in] time the number of ticks before the operation timeouts,
* the following special values are allowed:
* - @a TIME_IMMEDIATE immediate timeout.
@@ -151,7 +163,8 @@ void macReleaseTransmitDescriptor(MACTransmitDescriptor *tdp) {
* the operation timed out, the driver went in stop mode or some
* transient error happened.
*/
-MACReceiveDescriptor *macWaitReceiveDescriptor(systime_t time) {
+MACReceiveDescriptor *macWaitReceiveDescriptor(MACDriver *macp,
+ systime_t time) {
MACReceiveDescriptor *rdp;
chSysLock();
@@ -159,7 +172,7 @@ MACReceiveDescriptor *macWaitReceiveDescriptor(systime_t time) {
if ((state == ifStopped) || (chSemWaitTimeoutS(&rdsem, time) != RDY_OK))
rdp = NULL;
else
- rdp = max_lld_get_receive_descriptor();
+ rdp = max_lld_get_receive_descriptor(macp);
chSysUnlock();
return rdp;
@@ -170,12 +183,14 @@ MACReceiveDescriptor *macWaitReceiveDescriptor(systime_t time) {
* @details The descriptor and its buffer is made available for more incoming
* frames.
*
+ * @param[in] macp pointer to the @p MACDriver object
* @param[in] rdp the pointer to the @p MACReceiveDescriptor structure
*/
-void macReleaseReceiveDescriptor(MACReceiveDescriptor *rdp) {
+void macReleaseReceiveDescriptor(MACDriver *macp,
+ MACReceiveDescriptor *rdp) {
if (state == ifStarted)
- mac_lld_release_receive_descriptor(rdp);
+ mac_lld_release_receive_descriptor(macp, rdp);
}
/** @} */
diff --git a/os/io/mac.h b/os/io/mac.h
index b405f6814..e79f29919 100644
--- a/os/io/mac.h
+++ b/os/io/mac.h
@@ -49,14 +49,17 @@
extern "C" {
#endif
void macInit(void);
- void macSetAddress(uint8_t *p);
- void macStart(void);
- void macStop(void);
- MACTransmitDescriptor *macWaitTransmitDescriptor(systime_t time);
- void macReleaseTransmitDescriptor(MACTransmitDescriptor *tdp);
- void macAddTransmitData(MACTransmitDescriptor *tdp,
- uint8_t *buf,
- size_t size);
+ void macSetAddress(MACDriver *macp, uint8_t *p);
+ void macStart(MACDriver *macp);
+ void macStop(MACDriver *macp);
+ MACTransmitDescriptor *macWaitTransmitDescriptor(MACDriver *macp,
+ systime_t time);
+ void macReleaseTransmitDescriptor(MACDriver *macp,
+ MACTransmitDescriptor *tdp);
+ MACReceiveDescriptor *macWaitReceiveDescriptor(MACDriver *macp,
+ systime_t time);
+ void macReleaseReceiveDescriptor(MACDriver *macp,
+ MACReceiveDescriptor *rdp);
#ifdef __cplusplus
}
#endif
diff --git a/os/io/phy.c b/os/io/phy.c
new file mode 100644
index 000000000..d03c5b1d3
--- /dev/null
+++ b/os/io/phy.c
@@ -0,0 +1,30 @@
+/*
+ ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
+
+ This file is part of ChibiOS/RT.
+
+ ChibiOS/RT is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/RT is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file phy.c
+ * @brief PHY Driver code.
+ * @addtogroup PHY
+ * @{
+ */
+
+#include <ch.h>
+#include <phy.h>
+
+/** @} */
diff --git a/os/io/phy.h b/os/io/phy.h
new file mode 100644
index 000000000..7bf09b8c3
--- /dev/null
+++ b/os/io/phy.h
@@ -0,0 +1,42 @@
+/*
+ ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
+
+ This file is part of ChibiOS/RT.
+
+ ChibiOS/RT is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/RT is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file phy.h
+ * @brief PHY Driver macros and structures.
+ * @addtogroup PHY
+ * @{
+ */
+
+#ifndef _PHY_H_
+#define _PHY_H_
+
+#include "phy_lld.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void phyInit(void);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PHY_H_ */
+
+/** @} */
diff --git a/os/io/serial.h b/os/io/serial.h
index a70dcf7c4..6324a5f5b 100644
--- a/os/io/serial.h
+++ b/os/io/serial.h
@@ -42,6 +42,9 @@
/** Break detected.*/
#define SD_BREAK_DETECTED 32
+/**
+ * @brief Structure representing a serial driver.
+ */
typedef struct _SerialDriver SerialDriver;
#include "serial_lld.h"
diff --git a/os/io/templates/mac_lld.c b/os/io/templates/mac_lld.c
index 98c6f0c1d..100f871d2 100644
--- a/os/io/templates/mac_lld.c
+++ b/os/io/templates/mac_lld.c
@@ -37,6 +37,7 @@ void mac_lld_init(void) {
/**
* @brief Low level MAC address setup.
*
+ * @param[in] macp pointer to the @p MACDriver object
* @param[in] p pointer to a six bytes buffer containing the MAC address. If
* this parameter is set to @p NULL then a system default MAC is
* used.
@@ -44,21 +45,25 @@ void mac_lld_init(void) {
* @note This function should be invoked after the @p macInit() and before
* @p macStart() else the result is unspecified (performed or ignored).
*/
-void mac_lld_set_address(uint8_t *p) {
+void mac_lld_set_address(MACDriver *macp, uint8_t *p) {
}
/**
* @brief Starts the I/O activity and enters a low power mode.
+ *
+ * @param[in] macp pointer to the @p MACDriver object
*/
-void mac_lld_start(void) {
+void mac_lld_start(MACDriver *macp) {
}
/**
* @brief Stops the I/O activity.
+ *
+ * @param[in] macp pointer to the @p MACDriver object
*/
-void mac_lld_stop(void) {
+void mac_lld_stop(MACDriver *macp) {
}
@@ -67,10 +72,11 @@ void mac_lld_stop(void) {
* @details One of the available transmission descriptors is locked and
* returned.
*
+ * @param[in] macp pointer to the @p MACDriver object
* @return A pointer to a @p MACTransmitDescriptor structure or @p NULL if
* a descriptor is not available or the driver went in stop mode.
*/
-MACTransmitDescriptor *max_lld_get_transmit_descriptor(void) {
+MACTransmitDescriptor *max_lld_get_transmit_descriptor(MACDriver *macp) {
return NULL;
}
@@ -79,9 +85,11 @@ MACTransmitDescriptor *max_lld_get_transmit_descriptor(void) {
* @brief Releases a transmit descriptor and starts the transmission of the
* enqueued data as a single frame.
*
+ * @param[in] macp pointer to the @p MACDriver object
* @param[in] tdp the pointer to the @p MACTransmitDescriptor structure
*/
-void mac_lld_release_transmit_descriptor(MACTransmitDescriptor *tdp) {
+void mac_lld_release_transmit_descriptor(MACDriver *macp,
+ MACTransmitDescriptor *tdp) {
}
@@ -99,11 +107,12 @@ uint8_t *mac_lld_get_transmit_buffer(MACTransmitDescriptor *tdp) {
/**
* @brief Returns a received frame.
*
+ * @param[in] macp pointer to the @p MACDriver object
* @return A pointer to a @p MACReceiveDescriptor structure or @p NULL if
* the operation timed out, the driver went in stop mode or some
* transient error happened.
*/
-MACReceiveDescriptor *max_lld_get_receive_descriptor(void) {
+MACReceiveDescriptor *max_lld_get_receive_descriptor(MACDriver *macp) {
return NULL;
}
@@ -113,9 +122,11 @@ MACReceiveDescriptor *max_lld_get_receive_descriptor(void) {
* @details The descriptor and its buffer is made available for more incoming
* frames.
*
+ * @param[in] macp pointer to the @p MACDriver object
* @param[in] rdp the pointer to the @p MACReceiveDescriptor structure
*/
-void mac_lld_release_receive_descriptor(MACReceiveDescriptor *rdp) {
+void mac_lld_release_receive_descriptor(MACDriver *macp,
+ MACReceiveDescriptor *rdp) {
}
@@ -127,6 +138,7 @@ void mac_lld_release_receive_descriptor(MACReceiveDescriptor *rdp) {
*/
uint8_t *mac_lld_get_receive_buffer(MACReceiveDescriptor *rdp) {
+ return NULL;
}
/** @} */
diff --git a/os/io/templates/mac_lld.h b/os/io/templates/mac_lld.h
index 92e23cc4e..01889aa12 100644
--- a/os/io/templates/mac_lld.h
+++ b/os/io/templates/mac_lld.h
@@ -42,10 +42,23 @@
/* Driver data structures and types. */
/*===========================================================================*/
+/**
+ * @brief Structure representing a MAC driver.
+ */
+typedef struct {
+
+} MACDriver;
+
+/**
+ * @brief Structure representing a transmission descriptor.
+ */
typedef struct {
} MACTransmitDescriptor;
+/**
+ * @brief Structure representing a receive descriptor.
+ */
typedef struct {
} MACReceiveDescriptor;
@@ -58,14 +71,16 @@ typedef struct {
extern "C" {
#endif
void mac_lld_init(void);
- void mac_lld_set_address(uint8_t *p);
- void mac_lld_start(void);
- void mac_lld_stop(void);
- MACTransmitDescriptor *max_lld_get_transmit_descriptor(void);
- void mac_lld_release_transmit_descriptor(MACTransmitDescriptor *tdp);
+ void mac_lld_set_address(MACDriver *macp, uint8_t *p);
+ void mac_lld_start(MACDriver *macp);
+ void mac_lld_stop(MACDriver *macp);
+ MACTransmitDescriptor *max_lld_get_transmit_descriptor(MACDriver *macp);
+ void mac_lld_release_transmit_descriptor(MACDriver *macp,
+ MACTransmitDescriptor *tdp);
uint8_t *mac_lld_get_transmit_buffer(MACTransmitDescriptor *tdp);
- MACReceiveDescriptor *max_lld_get_receive_descriptor(void);
- void mac_lld_release_receive_descriptor(MACReceiveDescriptor *rdp);
+ MACReceiveDescriptor *max_lld_get_receive_descriptor(MACDriver *macp);
+ void mac_lld_release_receive_descriptor(MACDriver *macp,
+ MACReceiveDescriptor *rdp);
uint8_t *mac_lld_get_receive_buffer(MACReceiveDescriptor *rdp);
#ifdef __cplusplus
}