summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'boot_loader/examples/i2c/tftp/src/i2c_boot_tftp_example.c')
-rw-r--r--boot_loader/examples/i2c/tftp/src/i2c_boot_tftp_example.c113
1 files changed, 113 insertions, 0 deletions
diff --git a/boot_loader/examples/i2c/tftp/src/i2c_boot_tftp_example.c b/boot_loader/examples/i2c/tftp/src/i2c_boot_tftp_example.c
new file mode 100644
index 0000000..55e447c
--- /dev/null
+++ b/boot_loader/examples/i2c/tftp/src/i2c_boot_tftp_example.c
@@ -0,0 +1,113 @@
1/******************************************************************************
2 * Copyright (c) 2011 Texas Instruments Incorporated - http://www.ti.com
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the
14 * distribution.
15 *
16 * Neither the name of Texas Instruments Incorporated emac the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 *****************************************************************************/
33
34/**************************************************************************************
35 * FILE PURPOSE: EMAC Boot Over I2C Example
36 **************************************************************************************
37 * FILE NAME: i2c_boot_emac_example.c
38 *
39 * DESCRIPTION: A simple hello world example demonstrating EMAC boot over I2C.
40 *
41 ***************************************************************************************/
42#include <stdlib.h>
43#include <stdio.h>
44#include <string.h>
45#include "platform.h"
46
47#define BOOT_UART_BAUDRATE 115200
48
49/* i2c_boot_emac_example version */
50char version[] = "01.00.00.00";
51
52/******************************************************************************
53 * Function: print_platform_errno
54 ******************************************************************************/
55void
56print_platform_errno
57(
58 void
59)
60{
61 printf ("Returned platform error number is %d\n", platform_errno);
62}
63
64/******************************************************************************
65 * Function: write_uart
66 ******************************************************************************/
67void
68write_uart
69(
70 char* msg
71)
72{
73 uint32_t i;
74 uint32_t msg_len = strlen(msg);
75
76 /* Write the message to the UART */
77 for (i = 0; i < msg_len; i++)
78 {
79 platform_uart_write(msg[i]);
80 }
81}
82
83
84/******************************************************************************
85 * Function: main
86 ******************************************************************************/
87void main ()
88{
89 platform_init_flags init_flags;
90 platform_init_config init_config;
91 char version_msg[] = "\r\n\r\nEMAC Boot Over I2C Example Version ";
92 char boot_msg[] = "\r\n\r\nBooting Hello World image from EMAC via IBL over I2C 0x51 ...";
93
94 printf("%s%s\n\n", version_msg, version);
95
96 /* Initialize main Platform lib */
97 memset(&init_config, 0, sizeof(platform_init_config));
98 memset(&init_flags, 1, sizeof(platform_init_flags));
99 if (platform_init(&init_flags, &init_config) != Platform_EOK)
100 {
101 printf ("Platform init failed!\n");
102 print_platform_errno();
103 return;
104 }
105 platform_uart_init();
106 platform_uart_set_baudrate(BOOT_UART_BAUDRATE);
107
108 write_uart(version_msg);
109 write_uart(version);
110
111 printf("%s", boot_msg);
112 write_uart(boot_msg);
113}