Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed by
Revision 21:3944f1e2fa4f, committed 2010-06-17
- Comitter:
- simon
- Date:
- Thu Jun 17 16:23:14 2010 +0000
- Parent:
- 20:029aa53d7323
- Child:
- 22:9114680c05da
- Commit message:
- * CAN fixes
* Serial Interrupt
* I2C low level routines
Changed in this revision
--- a/CAN.h Thu Jun 03 11:17:50 2010 +0000
+++ b/CAN.h Thu Jun 17 16:23:14 2010 +0000
@@ -152,8 +152,9 @@
*
* Variables:
* hz - The bus frequency in hertz
+ * returns - 1 if successful, 0 otherwise
*/
- void frequency(int hz);
+ int frequency(int hz);
/* Function: write
* Write a CANMessage to the bus.
--- a/I2C.h Thu Jun 03 11:17:50 2010 +0000
+++ b/I2C.h Thu Jun 17 16:23:14 2010 +0000
@@ -40,6 +40,11 @@
, MasterRead
};
+ enum Acknowledge {
+ NoACK = 0
+ , ACK = 1
+ };
+
/* Constructor: I2C
* Create an I2C Master interface, connected to the specified pins
*
@@ -72,6 +77,15 @@
*/
int read(int address, char *data, int length, bool repeated = false);
+ /* Function: read
+ * Read a single byte from the I2C bus
+ *
+ * Variables:
+ * ack - indicates if the byte is to be acknowledged (1 = acknowledge)
+ * returns - the byte read
+ */
+ int read(int ack);
+
/* Function: write
* Write to an I2C slave
*
@@ -86,7 +100,27 @@
* returns - 0 on success (ack), or non-0 on failure (nack)
*/
int write(int address, const char *data, int length, bool repeated = false);
-
+
+ /* Function: write
+ * Write single byte out on the I2C bus
+ *
+ * Variables:
+ * data - data to write out on bus
+ * returns - a '1' if an ACK was retrieved, a '0' otherwise
+ */
+ int write(int data);
+
+ /* Function: start
+ * Creates a start condition on the I2C bus
+ */
+
+ void start(void);
+
+ /* Function: stop
+ * Creates a stop condition on the I2C bus
+ */
+ void stop(void);
+
protected:
void aquire();
--- a/LPC1768/LPC17xx.h Thu Jun 03 11:17:50 2010 +0000
+++ b/LPC1768/LPC17xx.h Thu Jun 17 16:23:14 2010 +0000
@@ -220,7 +220,7 @@
__I uint32_t CR1;
uint32_t RESERVED0[2];
__IO uint32_t EMR;
- uint32_t RESERVED1[24];
+ uint32_t RESERVED1[12];
__IO uint32_t CTCR;
} LPC_TIM_TypeDef;
Binary file LPC1768/capi.ar has changed
Binary file LPC1768/core_cm3.o has changed
Binary file LPC1768/mbed.ar has changed
--- a/LPC2368/LPC23xx.h Thu Jun 03 11:17:50 2010 +0000
+++ b/LPC2368/LPC23xx.h Thu Jun 17 16:23:14 2010 +0000
@@ -213,7 +213,7 @@
__I uint32_t CR1;
uint32_t RESERVED0[2];
__IO uint32_t EMR;
- uint32_t RESERVED1[24];
+ uint32_t RESERVED1[12];
__IO uint32_t CTCR;
} LPC_TIM_TypeDef;
Binary file LPC2368/capi.ar has changed
Binary file LPC2368/mbed.ar has changed
--- a/Serial.h Thu Jun 03 11:17:50 2010 +0000
+++ b/Serial.h Thu Jun 17 16:23:14 2010 +0000
@@ -59,6 +59,11 @@
, Forced0
};
+ enum IrqType {
+ RxIrq = 0
+ , TxIrq
+ };
+
/* Function: format
* Set the transmission format used by the Serial port
*
@@ -128,8 +133,9 @@
*
* Variables:
* fptr - A pointer to a void function, or 0 to set as none
+ * type - Which serial interrupt to attach the member function to (Seriall::RxIrq for receive, TxIrq for transmit buffer empty)
*/
- void attach(void (*fptr)(void));
+ void attach(void (*fptr)(void), IrqType type = RxIrq);
/* Function: attach
* Attach a member function to call whenever a serial interrupt is generated
@@ -137,11 +143,14 @@
* Variables:
* tptr - pointer to the object to call the member function on
* mptr - pointer to the member function to be called
+ * type - Which serial interrupt to attach the member function to (Seriall::RxIrq for receive, TxIrq for transmit buffer empty)
*/
template<typename T>
- void attach(T* tptr, void (T::*mptr)(void)) {
- _irq.attach(tptr, mptr);
- setup_interrupt();
+ void attach(T* tptr, void (T::*mptr)(void), IrqType type = RxIrq) {
+ if((mptr != NULL) && (tptr != NULL)) {
+ _irq[type].attach(tptr, mptr);
+ setup_interrupt(type);
+ }
}
#ifdef MBED_RPC
@@ -151,14 +160,15 @@
protected:
- void setup_interrupt();
- void remove_interrupt();
+ void setup_interrupt(IrqType type);
+ void remove_interrupt(IrqType type);
virtual int _getc();
virtual int _putc(int c);
UARTName _uart;
- FunctionPointer _irq;
+ FunctionPointer _irq[2];
+ int _uidx;
};
--- a/mbed.h Thu Jun 03 11:17:50 2010 +0000 +++ b/mbed.h Thu Jun 17 16:23:14 2010 +0000 @@ -6,7 +6,7 @@ #ifndef MBED_H #define MBED_H -#define MBED_LIBRARY_VERSION 22 +#define MBED_LIBRARY_VERSION 23 // Useful C libraries #include <stdio.h>
