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 I2Cboot by
Revision 5:0801179037cd, committed 2015-05-24
- Comitter:
- Piasiv1206
- Date:
- Sun May 24 22:46:31 2015 +0000
- Parent:
- 1:c39e5581f901
- Commit message:
- Instructions given in the code ; Blinky code has been loaded; fingers crossed
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r c39e5581f901 -r 0801179037cd main.cpp --- a/main.cpp Sat May 23 23:04:50 2015 +0000 +++ b/main.cpp Sun May 24 22:46:31 2015 +0000 @@ -1,19 +1,30 @@ #include "mbed.h" #include <stdbool.h> #include <stdint.h> -#include <fcntl.h> +//#include <fcntl.h> #include <stdlib.h> #include <stdio.h> -#include <memory.h> +//#include <memory.h> + + +/* +Use pull up resistors +Test Sample I2C with Tiva +Learn about the I2C in freescale boards +Check I2CReceiveData and I2CSendData compatibitily with Tiva +Now Use ROM boot loader +if it works get the flash code from CDMS people and try with that + +*/ // BootLoader Serial pc(USBTX, USBRX); // tx, rx -I2C i2c(p28, p27); +I2C i2c(D15, D14); -const int addr = 0x90; +const int addr = 0x42; #define COMMAND_PING 0x20 #define COMMAND_DOWNLOAD 0x21 @@ -52,6 +63,7 @@ uint32_t g_ui32DataSize; uint8_t g_pui8Buffer[256]; +uint8_t CheckSum(uint8_t *pui8Data, uint8_t ui8Size); // @@ -59,24 +71,46 @@ I2CSendData(uint8_t const *pui8Data, uint8_t ui8Size) { - if(i2c.write(addr, pui8Data, ui8Size) == 1) - { - return (0); - } - - else - - { - return (-1); - } - + int i; + char temp[ui8Size]; + + + + for(i=0;i<ui8Size;i++) + { + + temp[i] = pui8Data[i]; + + } + + + if(i2c.write(addr, temp, ui8Size,0) == 0) + { + return (0); + } + + return (-1); } int I2CReceiveData(uint8_t *pui8Data, uint8_t ui8Size) { - if(i2c.read(addr, pui8Data, ui8Size == 0) + + int i; + char temp[ui8Size]; + + + + for(i=0;i<ui8Size;i++) + { + + temp[i] = pui8Data[i]; + + } + + + if(i2c.read(addr, temp, ui8Size,0) == 0) { return (0); } @@ -96,6 +130,11 @@ //! value indicates a failure. // //**************************************************************************** + + + + + int32_t AckPacket(void) { @@ -346,19 +385,47 @@ uint8_t ui8Command; - uint32_t ui32TransferLength; - uint8_t *pui8FileBuffer; + uint32_t ui32TransferLength = 1424; uint32_t ui32Offset; + uint8_t pui8FileBuffer[] = {0 , 1 , 0 , 32 , 95 , 5 , 0 , 0 , 109 , 5 , 0 , 0 , 251 , 3 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 0 , 0 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 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107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 107 , 5 , 0 , 0 , 0 , 42 , 74 , 208 , 95 , 234 , 0 , 12 , 139 , 7 , 28 , 209 , 131 , 7 , 34 , 209 , 16 , 42 , 8 , 211 , 112 , 180 , 16 , 58 , 120 , 201 , 120 , 192 , 16 , 58 , 251 , 210 , 112 , 188 , 16 , 50 , 56 , 208 , 4 , 42 , 44 , 211 , 8 , 42 , 5 , 211 , 12 , 42 , 36 , 191 , 8 , 201 , 8 , 192 , 8 , 201 , 8 , 192 , 8 , 201 , 8 , 192 , 146 , 7 , 42 , 208 , 146 , 15 , 34 , 224 , 11 , 120 , 3 , 112 , 73 , 28 , 64 , 28 , 82 , 30 , 34 , 208 , 139 , 7 , 247 , 209 , 195 , 7 , 20 , 209 , 131 , 7 , 216 , 208 , 18 , 31 , 18 , 211 , 8 , 201 , 3 , 128 , 27 , 12 , 67 , 128 , 0 , 29 , 18 , 31 , 248 , 210 , 10 , 224 , 8 , 201 , 3 , 112 , 27 , 10 , 67 , 112 , 27 , 10 , 131 , 112 , 27 , 10 , 195 , 112 , 0 , 29 , 18 , 31 , 244 , 210 , 18 , 29 , 5 , 208 , 11 , 120 , 3 , 112 , 73 , 28 , 64 , 28 , 82 , 30 , 249 , 209 , 96 , 70 , 112 , 71 , 240 , 181 , 30 , 72 , 1 , 39 , 248 , 66 , 1 , 208 , 0 , 240 , 195 , 248 , 30 , 77 , 30 , 79 , 31 , 78 , 189 , 66 , 6 , 210 , 3 , 205 , 4 , 120 , 164 , 0 , 52 , 89 , 64 , 28 , 160 , 71 , 246 , 231 , 22 , 77 , 22 , 79 , 189 , 66 , 2 , 210 , 16 , 205 , 160 , 71 , 250 , 231 , 240 , 189 , 3 , 37 , 27 , 224 , 65 , 104 , 8 , 48 , 10 , 28 , 42 , 64 , 11 , 209 , 26 , 28 , 42 , 64 , 171 , 67 , 5 , 208 , 4 , 104 , 4 , 48 , 12 , 96 , 4 , 49 , 4 , 59 , 249 , 209 , 19 , 28 , 5 , 208 , 4 , 120 , 1 , 48 , 12 , 112 , 1 , 49 , 1 , 59 , 249 , 209 , 2 , 28 , 42 , 64 , 1 , 208 , 168 , 67 , 4 , 48 , 3 , 104 , 0 , 43 , 224 , 209 , 112 , 71 , 192 , 70 , 255 , 255 , 255 , 255 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 136 , 5 , 0 , 0 , 144 , 5 , 0 , 0 , 128 , 5 , 0 , 0 , 112 , 181 , 16 , 248 , 1 , 75 , 27 , 224 , 64 , 28 , 90 , 177 , 29 , 10 , 9 , 209 , 2 , 37 , 16 , 248 , 1 , 107 , 109 , 30 , 70 , 234 , 3 , 35 , 249 , 209 , 1 , 224 , 4 , 43 , 2 , 211 , 16 , 248 , 1 , 91 , 3 , 224 , 37 , 70 , 1 , 224 , 1 , 248 , 1 , 91 , 91 , 30 , 179 , 241 , 255 , 63 , 249 , 209 , 1 , 224 , 1 , 248 , 1 , 59 , 16 , 248 , 1 , 59 , 156 , 66 , 249 , 209 , 16 , 248 , 1 , 59 , 0 , 43 , 231 , 209 , 16 , 248 , 1 , 91 , 3 , 120 , 45 , 2 , 91 , 25 , 213 , 209 , 112 , 189 , 254 , 231 , 18 , 72 , 19 , 75 , 32 , 33 , 1 , 96 , 2 , 104 , 18 , 73 , 173 , 241 , 8 , 13 , 0 , 146 , 2 , 32 , 88 , 96 , 0 , 34 , 195 , 248 , 32 , 1 , 24 , 104 , 64 , 240 , 2 , 0 , 24 , 96 , 0 , 146 , 0 , 152 , 129 , 66 , 11 , 216 , 24 , 104 , 32 , 240 , 2 , 0 , 24 , 96 , 0 , 146 , 0 , 152 , 129 , 66 , 239 , 217 , 0 , 152 , 64 , 28 , 0 , 144 , 248 , 231 , 0 , 152 , 64 , 28 , 0 , 144 , 236 , 231 , 8 , 225 , 15 , 64 , 252 , 83 , 2 , 64 , 64 , 13 , 3 , 0 , 78 , 246 , 136 , 81 , 206 , 242 , 0 , 1 , 8 , 104 , 79 , 240 , 240 , 3 , 64 , 234 , 3 , 64 , 8 , 96 , 9 , 72 , 133 , 70 , 9 , 72 , 133 , 68 , 111 , 70 , 7 , 32 , 135 , 67 , 189 , 70 , 7 , 72 , 111 , 70 , 7 , 96 , 255 , 247 , 67 , 255 , 0 , 240 , 79 , 248 , 1 , 32 , 0 , 240 , 48 , 248 , 254 , 231 , 192 , 70 , 0 , 0 , 0 , 32 , 0 , 1 , 0 , 0 , 16 , 1 , 0 , 32 , 112 , 181 , 15 , 77 , 6 , 70 , 115 , 136 , 0 , 36 , 22 , 224 , 160 , 0 , 0 , 235 , 196 , 0 , 48 , 24 , 65 , 104 , 194 , 104 , 128 , 104 , 74 , 185 , 42 , 104 , 82 , 177 , 10 , 120 , 85 , 248 , 34 , 48 , 74 , 28 , 1 , 70 , 16 , 70 , 152 , 71 , 1 , 224 , 255 , 247 , 206 , 254 , 115 , 136 , 100 , 28 , 164 , 178 , 163 , 66 , 230 , 220 , 112 , 189 , 128 , 5 , 0 , 0 , 0 , 191 , 112 , 71 , 8 , 181 , 255 , 247 , 251 , 255 , 254 , 231 , 56 , 181 , 5 , 70 , 9 , 72 , 0 , 104 , 128 , 71 , 9 , 76 , 32 , 29 , 0 , 104 , 16 , 177 , 1 , 70 , 40 , 70 , 136 , 71 , 32 , 104 , 0 , 177 , 128 , 71 , 5 , 72 , 0 , 104 , 128 , 71 , 255 , 247 , 232 , 255 , 56 , 189 , 192 , 70 , 0 , 1 , 0 , 32 , 8 , 1 , 0 , 32 , 4 , 1 , 0 , 32 , 4 , 73 , 177 , 241 , 255 , 63 , 7 , 191 , 0 , 33 , 8 , 28 , 8 , 104 , 9 , 29 , 255 , 247 , 98 , 191 , 255 , 255 , 255 , 255 , 3 , 73 , 8 , 96 , 112 , 71 , 2 , 73 , 9 , 31 , 8 , 96 , 112 , 71 , 112 , 71 , 4 , 1 , 0 , 32 , 208 , 248 , 3 , 32 , 195 , 29 , 8 , 70 , 25 , 70 , 255 , 247 , 135 , 190 , 255 , 247 , 121 , 191 , 112 , 71 , 1 , 34 , 255 , 247 , 25 , 191 , 254 , 231 , 254 , 231 , 0 , 0 , 0 , 1 , 75 , 5 , 0 , 0 , 75 , 5 , 1 , 14 , 0 , 1 , 0 , 0 , 0 , 0 , 101 , 5 , 0 , 0 , 81 , 5 , 0 , 0 , 112 , 5 , 0 , 0 , 0 , 1 , 0 , 32}; + - g_pui8Buffer[0] = COMMAND_DOWNLOAD; - g_pui8Buffer[1] = (uint8_t)(g_ui32DownloadAddress >> 24); - g_pui8Buffer[2] = (uint8_t)(g_ui32DownloadAddress >> 16); - g_pui8Buffer[3] = (uint8_t)(g_ui32DownloadAddress >> 8); - g_pui8Buffer[4] = (uint8_t)g_ui32DownloadAddress; - g_pui8Buffer[5] = (uint8_t)(ui32TransferLength>>24); - g_pui8Buffer[6] = (uint8_t)(ui32TransferLength>>16); - g_pui8Buffer[7] = (uint8_t)(ui32TransferLength>>8); - g_pui8Buffer[8] = (uint8_t)ui32TransferLength; + if(g_ui32StartAddress != 0xffffffff) + { + // + // Send the run command but just send the packet, there will likely + // be no boot loader to answer after this command completes. + // + g_pui8Buffer[0] = COMMAND_RUN; + g_pui8Buffer[1] = (uint8_t)(g_ui32StartAddress>>24); + g_pui8Buffer[2] = (uint8_t)(g_ui32StartAddress>>16); + g_pui8Buffer[3] = (uint8_t)(g_ui32StartAddress>>8); + g_pui8Buffer[4] = (uint8_t)g_ui32StartAddress; + if(SendPacket(g_pui8Buffer, 5, 0) < 0) + { + printf("Failed to Send Run command\n"); + } + else + { + printf("Running from address %08x\n",g_ui32StartAddress); + } + + } + + else + { + + g_pui8Buffer[0] = COMMAND_DOWNLOAD; + g_pui8Buffer[1] = (uint8_t)(g_ui32DownloadAddress >> 24); + g_pui8Buffer[2] = (uint8_t)(g_ui32DownloadAddress >> 16); + g_pui8Buffer[3] = (uint8_t)(g_ui32DownloadAddress >> 8); + g_pui8Buffer[4] = (uint8_t)g_ui32DownloadAddress; + g_pui8Buffer[5] = (uint8_t)(ui32TransferLength>>24); + g_pui8Buffer[6] = (uint8_t)(ui32TransferLength>>16); + g_pui8Buffer[7] = (uint8_t)(ui32TransferLength>>8); + g_pui8Buffer[8] = (uint8_t)ui32TransferLength; + } + ui8Command = COMMAND_PING; if(SendCommand(&ui8Command, 1) < 0)