blob: c79d5aa887dfa335827599badd72137c75757238 [file] [log] [blame]
Kévin Redon69b92d92019-01-24 16:39:20 +01001/*
Kévin Redon78d2f442019-01-24 18:45:59 +01002 * Copyright (C) 2019 sysmocom -s.f.m.c. GmbH, Author: Kevin Redon <kredon@sysmocom.de>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17*/
Kévin Redon69b92d92019-01-24 16:39:20 +010018
Harald Weltef53f2262019-02-24 11:01:08 +010019#include <parts.h>
20#include <hal_cache.h>
Harald Welte93f628a2019-02-24 14:32:30 +010021#include <hri_port_e54.h>
Harald Weltef53f2262019-02-24 11:01:08 +010022
Kévin Redon69b92d92019-01-24 16:39:20 +010023#include "atmel_start.h"
24#include "atmel_start_pins.h"
25
Harald Weltec3f170d2019-02-24 09:06:59 +010026#include "i2c_bitbang.h"
27#include "octsim_i2c.h"
28#include "ncn8025.h"
29
Kévin Redon78d2f442019-01-24 18:45:59 +010030
Harald Weltec3f170d2019-02-24 09:06:59 +010031static void board_init()
32{
33 int i;
34
35 for (i = 0; i < 4; i++)
36 i2c_init(&i2c[i]);
37
38 /* only 7 slots, as last slot is debug uart! */
39 for (i = 0; i < 7; i++)
40 ncn8025_init(i);
Harald Weltef53f2262019-02-24 11:01:08 +010041
42 cache_init();
43 cache_enable(CMCC);
Harald Welte93f628a2019-02-24 14:32:30 +010044
45 /* increase drive strength of 20Mhz SIM clock output to 8mA
46 * (there are 8 inputs + traces to drive!) */
47 hri_port_set_PINCFG_DRVSTR_bit(PORT, 0, 11);
Harald Weltec3f170d2019-02-24 09:06:59 +010048}
49
Kévin Redon69b92d92019-01-24 16:39:20 +010050int main(void)
51{
52 atmel_start_init();
Kévin Redon78d2f442019-01-24 18:45:59 +010053
Harald Welte361ed202019-02-24 21:15:39 +010054 usart_sync_enable(&UART_debug);
Kévin Redon78d2f442019-01-24 18:45:59 +010055
Kévin Redon8e538002019-01-30 11:19:19 +010056 usb_start();
57
Harald Weltec3f170d2019-02-24 09:06:59 +010058 board_init();
59
Harald Welte361ed202019-02-24 21:15:39 +010060 printf("\r\n\r\nsysmocom sysmoOCTSIM\r\n");
Kévin Redon8e538002019-01-30 11:19:19 +010061 while (true) { // main loop
Harald Welte361ed202019-02-24 21:15:39 +010062 if (usart_sync_is_rx_not_empty(&UART_debug)) {
63 gpio_toggle_pin_level(USER_LED);
64 int c = getchar();
65 putchar(c);
Kévin Redon8e538002019-01-30 11:19:19 +010066 }
67 }
Kévin Redon69b92d92019-01-24 16:39:20 +010068}