The official mbed C/C SDK provides the software platform and libraries to build your applications.
Fork of mbed by
(01.May.2014) started sales! http://www.switch-science.com/catalog/1717/
(13.March.2014) updated to 0.5.0
This is a pin conversion PCB from mbed 1768/11U24 to arduino UNO.
- So if you have both mbed and arduino shields, I guess you would be happy with such a conversion board :)
Photos
- Board photo vvv
- Schematic photo vvv
- Functionality photo vvv
Latest eagle files
PCB >> /media/uploads/k4zuki/mbedshield050.brd
SCH >> /media/uploads/k4zuki/mbedshield050.sch
BIG changes from previous version
- Ethernet RJ45 connector is removed.
- http://mbed.org/components/Seeed-Ethernet-Shield-V20/ is the biggest hint to use Ethernet!
MostALL of components can be bought at Akizuki http://akizukidenshi.com/- But sorry, they do not send parts to abroad
- Pinout is changed!
arduino | 0.4.0 | 0.5.0 |
---|---|---|
D4 | p12 | p21 |
D5 | p11 | p22 |
MOSI_ | none | p11 |
MISO_ | none | p12 |
SCK_ | none | p13 |
This design has bug(s)
- I2C functional pin differs between 1768 and 11U24.
Fixed bugs here
- MiniUSB cable cannot be connected on mbed if you solder high-height electrolytic capacitor on C3.
- http://akizukidenshi.com/catalog/g/gP-05002/ is the solution to make this 100% AKIZUKI parts!
- the 6-pin ISP port is not inprimented in version 0.4.0
it will be fixed in later version 0.4.1/0.4.2/0.5.0This has beenfixed
I am doing some porting to use existing arduino shields but it may faster if you do it by yourself...
you can use arduino PinName "A0-A5,D0-D13" plus backside SPI port for easier porting.
To do this you have to edit PinName enum in
- "mbed/TARGET_LPC1768/PinNames.h" or
- "mbed/TARGET_LPC11U24/PinNames.h" as per your target mbed.
here is the actual list: This list includes define switch to switch pin assignment
part_of_PinNames.h
USBTX = P0_2, USBRX = P0_3, //from here mbeDshield mod D0=p27, D1=p28, D2=p14, D3=p13, #ifdef MBEDSHIELD_050 MOSI_=p11, MISO_=p12, SCK_=p13, D4=p21, D5=p22, #else D4=p12, D5=p11, #endif D6=p23, D7=p24, D8=p25, D9=p26, D10=p8, D11=p5, D12=p6, D13=p7, A0=p15, A1=p16, A2=p17, A3=p18, A4=p19, A5=p20, SDA=p9, SCL=p10, //mbeDshield mod ends here // Not connected NC = (int)0xFFFFFFFF
CAN.h@59:0883845fe643, 2013-02-18 (annotated)
- Committer:
- emilmont
- Date:
- Mon Feb 18 11:12:58 2013 +0000
- Revision:
- 59:0883845fe643
- Parent:
- 55:d722ed6a4237
- Child:
- 65:5798e58a58b1
Add pinmap NC terminators for LPC1768 CAN.
Update the license from MIT to Apache v2.
Make the semihost code target independent using opportune defines for the UID and MAC.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 44:24d45a770a51 | 1 | /* mbed Microcontroller Library |
emilmont | 54:71b101360fb9 | 2 | * Copyright (c) 2006-2013 ARM Limited |
emilmont | 44:24d45a770a51 | 3 | * |
emilmont | 59:0883845fe643 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
emilmont | 59:0883845fe643 | 5 | * you may not use this file except in compliance with the License. |
emilmont | 59:0883845fe643 | 6 | * You may obtain a copy of the License at |
emilmont | 59:0883845fe643 | 7 | * |
emilmont | 59:0883845fe643 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
emilmont | 44:24d45a770a51 | 9 | * |
emilmont | 59:0883845fe643 | 10 | * Unless required by applicable law or agreed to in writing, software |
emilmont | 59:0883845fe643 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
emilmont | 59:0883845fe643 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
emilmont | 59:0883845fe643 | 13 | * See the License for the specific language governing permissions and |
emilmont | 59:0883845fe643 | 14 | * limitations under the License. |
emilmont | 44:24d45a770a51 | 15 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 16 | #ifndef MBED_CAN_H |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 17 | #define MBED_CAN_H |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 18 | |
emilmont | 44:24d45a770a51 | 19 | #include "platform.h" |
emilmont | 27:7110ebee3484 | 20 | |
emilmont | 27:7110ebee3484 | 21 | #if DEVICE_CAN |
emilmont | 27:7110ebee3484 | 22 | |
emilmont | 44:24d45a770a51 | 23 | #include "can_api.h" |
emilmont | 55:d722ed6a4237 | 24 | #include "can_helper.h" |
simon | 22:9114680c05da | 25 | #include "FunctionPointer.h" |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 26 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 27 | namespace mbed { |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 28 | |
emilmont | 43:e2ed12d17f06 | 29 | /** CANMessage class |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 30 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 31 | class CANMessage : public CAN_Message { |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 32 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 33 | public: |
emilmont | 43:e2ed12d17f06 | 34 | /** Creates empty CAN message. |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 35 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 36 | CANMessage() { |
emilmont | 44:24d45a770a51 | 37 | len = 8; |
emilmont | 44:24d45a770a51 | 38 | type = CANData; |
emilmont | 44:24d45a770a51 | 39 | format = CANStandard; |
emilmont | 44:24d45a770a51 | 40 | id = 0; |
emilmont | 44:24d45a770a51 | 41 | memset(data, 0, 8); |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 42 | } |
emilmont | 55:d722ed6a4237 | 43 | |
emilmont | 43:e2ed12d17f06 | 44 | /** Creates CAN message with specific content. |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 45 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 46 | CANMessage(int _id, const char *_data, char _len = 8, CANType _type = CANData, CANFormat _format = CANStandard) { |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 47 | len = _len & 0xF; |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 48 | type = _type; |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 49 | format = _format; |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 50 | id = _id; |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 51 | memcpy(data, _data, _len); |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 52 | } |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 53 | |
emilmont | 43:e2ed12d17f06 | 54 | /** Creates CAN remote message. |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 55 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 56 | CANMessage(int _id, CANFormat _format = CANStandard) { |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 57 | len = 0; |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 58 | type = CANRemote; |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 59 | format = _format; |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 60 | id = _id; |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 61 | memset(data, 0, 8); |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 62 | } |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 63 | }; |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 64 | |
emilmont | 43:e2ed12d17f06 | 65 | /** A can bus client, used for communicating with can devices |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 66 | */ |
emilmont | 44:24d45a770a51 | 67 | class CAN { |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 68 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 69 | public: |
emilmont | 43:e2ed12d17f06 | 70 | /** Creates an CAN interface connected to specific pins. |
emilmont | 43:e2ed12d17f06 | 71 | * |
emilmont | 43:e2ed12d17f06 | 72 | * @param rd read from transmitter |
emilmont | 43:e2ed12d17f06 | 73 | * @param td transmit to transmitter |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 74 | * |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 75 | * Example: |
emilmont | 43:e2ed12d17f06 | 76 | * @code |
emilmont | 43:e2ed12d17f06 | 77 | * #include "mbed.h" |
emilmont | 55:d722ed6a4237 | 78 | * |
emilmont | 43:e2ed12d17f06 | 79 | * Ticker ticker; |
emilmont | 43:e2ed12d17f06 | 80 | * DigitalOut led1(LED1); |
emilmont | 43:e2ed12d17f06 | 81 | * DigitalOut led2(LED2); |
emilmont | 43:e2ed12d17f06 | 82 | * CAN can1(p9, p10); |
emilmont | 43:e2ed12d17f06 | 83 | * CAN can2(p30, p29); |
emilmont | 55:d722ed6a4237 | 84 | * |
emilmont | 43:e2ed12d17f06 | 85 | * char counter = 0; |
emilmont | 55:d722ed6a4237 | 86 | * |
emilmont | 43:e2ed12d17f06 | 87 | * void send() { |
emilmont | 43:e2ed12d17f06 | 88 | * if(can1.write(CANMessage(1337, &counter, 1))) { |
emilmont | 43:e2ed12d17f06 | 89 | * printf("Message sent: %d\n", counter); |
emilmont | 43:e2ed12d17f06 | 90 | * counter++; |
emilmont | 55:d722ed6a4237 | 91 | * } |
emilmont | 43:e2ed12d17f06 | 92 | * led1 = !led1; |
emilmont | 43:e2ed12d17f06 | 93 | * } |
emilmont | 55:d722ed6a4237 | 94 | * |
emilmont | 43:e2ed12d17f06 | 95 | * int main() { |
emilmont | 43:e2ed12d17f06 | 96 | * ticker.attach(&send, 1); |
emilmont | 43:e2ed12d17f06 | 97 | * CANMessage msg; |
emilmont | 43:e2ed12d17f06 | 98 | * while(1) { |
emilmont | 43:e2ed12d17f06 | 99 | * if(can2.read(msg)) { |
emilmont | 43:e2ed12d17f06 | 100 | * printf("Message received: %d\n\n", msg.data[0]); |
emilmont | 43:e2ed12d17f06 | 101 | * led2 = !led2; |
emilmont | 55:d722ed6a4237 | 102 | * } |
emilmont | 43:e2ed12d17f06 | 103 | * wait(0.2); |
emilmont | 43:e2ed12d17f06 | 104 | * } |
emilmont | 55:d722ed6a4237 | 105 | * } |
emilmont | 43:e2ed12d17f06 | 106 | * @endcode |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 107 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 108 | CAN(PinName rd, PinName td); |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 109 | virtual ~CAN(); |
emilmont | 55:d722ed6a4237 | 110 | |
emilmont | 43:e2ed12d17f06 | 111 | /** Set the frequency of the CAN interface |
emilmont | 43:e2ed12d17f06 | 112 | * |
emilmont | 43:e2ed12d17f06 | 113 | * @param hz The bus frequency in hertz |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 114 | * |
emilmont | 43:e2ed12d17f06 | 115 | * @returns |
emilmont | 43:e2ed12d17f06 | 116 | * 1 if successful, |
emilmont | 43:e2ed12d17f06 | 117 | * 0 otherwise |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 118 | */ |
simon | 21:3944f1e2fa4f | 119 | int frequency(int hz); |
emilmont | 55:d722ed6a4237 | 120 | |
emilmont | 43:e2ed12d17f06 | 121 | /** Write a CANMessage to the bus. |
emilmont | 43:e2ed12d17f06 | 122 | * |
emilmont | 43:e2ed12d17f06 | 123 | * @param msg The CANMessage to write. |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 124 | * |
emilmont | 43:e2ed12d17f06 | 125 | * @returns |
emilmont | 43:e2ed12d17f06 | 126 | * 0 if write failed, |
emilmont | 43:e2ed12d17f06 | 127 | * 1 if write was successful |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 128 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 129 | int write(CANMessage msg); |
emilmont | 55:d722ed6a4237 | 130 | |
emilmont | 43:e2ed12d17f06 | 131 | /** Read a CANMessage from the bus. |
emilmont | 55:d722ed6a4237 | 132 | * |
emilmont | 43:e2ed12d17f06 | 133 | * @param msg A CANMessage to read to. |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 134 | * |
emilmont | 43:e2ed12d17f06 | 135 | * @returns |
emilmont | 43:e2ed12d17f06 | 136 | * 0 if no message arrived, |
emilmont | 43:e2ed12d17f06 | 137 | * 1 if message arrived |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 138 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 139 | int read(CANMessage &msg); |
emilmont | 55:d722ed6a4237 | 140 | |
emilmont | 43:e2ed12d17f06 | 141 | /** Reset CAN interface. |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 142 | * |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 143 | * To use after error overflow. |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 144 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 145 | void reset(); |
emilmont | 55:d722ed6a4237 | 146 | |
emilmont | 43:e2ed12d17f06 | 147 | /** Puts or removes the CAN interface into silent monitoring mode |
simon | 22:9114680c05da | 148 | * |
emilmont | 43:e2ed12d17f06 | 149 | * @param silent boolean indicating whether to go into silent mode or not |
simon | 22:9114680c05da | 150 | */ |
simon | 22:9114680c05da | 151 | void monitor(bool silent); |
emilmont | 55:d722ed6a4237 | 152 | |
emilmont | 43:e2ed12d17f06 | 153 | /** Returns number of read errors to detect read overflow errors. |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 154 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 155 | unsigned char rderror(); |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 156 | |
emilmont | 43:e2ed12d17f06 | 157 | /** Returns number of write errors to detect write overflow errors. |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 158 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 159 | unsigned char tderror(); |
simon | 22:9114680c05da | 160 | |
emilmont | 43:e2ed12d17f06 | 161 | /** Attach a function to call whenever a CAN frame received interrupt is |
simon | 22:9114680c05da | 162 | * generated. |
simon | 22:9114680c05da | 163 | * |
emilmont | 43:e2ed12d17f06 | 164 | * @param fptr A pointer to a void function, or 0 to set as none |
simon | 22:9114680c05da | 165 | */ |
simon | 22:9114680c05da | 166 | void attach(void (*fptr)(void)); |
emilmont | 55:d722ed6a4237 | 167 | |
emilmont | 43:e2ed12d17f06 | 168 | /** Attach a member function to call whenever a CAN frame received interrupt |
simon | 22:9114680c05da | 169 | * is generated. |
simon | 22:9114680c05da | 170 | * |
emilmont | 43:e2ed12d17f06 | 171 | * @param tptr pointer to the object to call the member function on |
emilmont | 43:e2ed12d17f06 | 172 | * @param mptr pointer to the member function to be called |
simon | 22:9114680c05da | 173 | */ |
simon | 22:9114680c05da | 174 | template<typename T> |
emilmont | 33:5364839841bd | 175 | void attach(T* tptr, void (T::*mptr)(void)) { |
emilmont | 33:5364839841bd | 176 | if((mptr != NULL) && (tptr != NULL)) { |
emilmont | 33:5364839841bd | 177 | _rxirq.attach(tptr, mptr); |
emilmont | 33:5364839841bd | 178 | setup_interrupt(); |
emilmont | 33:5364839841bd | 179 | } else { |
emilmont | 33:5364839841bd | 180 | remove_interrupt(); |
emilmont | 33:5364839841bd | 181 | } |
emilmont | 33:5364839841bd | 182 | } |
emilmont | 55:d722ed6a4237 | 183 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 184 | private: |
emilmont | 44:24d45a770a51 | 185 | can_t _can; |
simon | 22:9114680c05da | 186 | FunctionPointer _rxirq; |
emilmont | 55:d722ed6a4237 | 187 | |
simon | 22:9114680c05da | 188 | void setup_interrupt(void); |
simon | 22:9114680c05da | 189 | void remove_interrupt(void); |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 190 | }; |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 191 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 192 | } // namespace mbed |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 193 | |
emilmont | 44:24d45a770a51 | 194 | #endif |
emilmont | 27:7110ebee3484 | 195 | |
emilmont | 44:24d45a770a51 | 196 | #endif // MBED_CAN_H |