Kévin Redon | 69b92d9 | 2019-01-24 16:39:20 +0100 | [diff] [blame] | 1 | /* |
Kévin Redon | 78d2f44 | 2019-01-24 18:45:59 +0100 | [diff] [blame] | 2 | * 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 Redon | 69b92d9 | 2019-01-24 16:39:20 +0100 | [diff] [blame] | 18 | |
Harald Welte | f53f226 | 2019-02-24 11:01:08 +0100 | [diff] [blame] | 19 | #include <parts.h> |
| 20 | #include <hal_cache.h> |
Harald Welte | 93f628a | 2019-02-24 14:32:30 +0100 | [diff] [blame] | 21 | #include <hri_port_e54.h> |
Harald Welte | f53f226 | 2019-02-24 11:01:08 +0100 | [diff] [blame] | 22 | |
Kévin Redon | 69b92d9 | 2019-01-24 16:39:20 +0100 | [diff] [blame] | 23 | #include "atmel_start.h" |
| 24 | #include "atmel_start_pins.h" |
| 25 | |
Harald Welte | c3f170d | 2019-02-24 09:06:59 +0100 | [diff] [blame] | 26 | #include "i2c_bitbang.h" |
| 27 | #include "octsim_i2c.h" |
| 28 | #include "ncn8025.h" |
| 29 | |
Kévin Redon | 78d2f44 | 2019-01-24 18:45:59 +0100 | [diff] [blame] | 30 | |
Harald Welte | c3f170d | 2019-02-24 09:06:59 +0100 | [diff] [blame] | 31 | static 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 Welte | f53f226 | 2019-02-24 11:01:08 +0100 | [diff] [blame] | 41 | |
| 42 | cache_init(); |
| 43 | cache_enable(CMCC); |
Harald Welte | 93f628a | 2019-02-24 14:32:30 +0100 | [diff] [blame] | 44 | |
| 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 Welte | c3f170d | 2019-02-24 09:06:59 +0100 | [diff] [blame] | 48 | } |
| 49 | |
Kévin Redon | 69b92d9 | 2019-01-24 16:39:20 +0100 | [diff] [blame] | 50 | int main(void) |
| 51 | { |
| 52 | atmel_start_init(); |
Kévin Redon | 78d2f44 | 2019-01-24 18:45:59 +0100 | [diff] [blame] | 53 | |
Harald Welte | 361ed20 | 2019-02-24 21:15:39 +0100 | [diff] [blame] | 54 | usart_sync_enable(&UART_debug); |
Kévin Redon | 78d2f44 | 2019-01-24 18:45:59 +0100 | [diff] [blame] | 55 | |
Kévin Redon | 8e53800 | 2019-01-30 11:19:19 +0100 | [diff] [blame] | 56 | usb_start(); |
| 57 | |
Harald Welte | c3f170d | 2019-02-24 09:06:59 +0100 | [diff] [blame] | 58 | board_init(); |
| 59 | |
Harald Welte | 361ed20 | 2019-02-24 21:15:39 +0100 | [diff] [blame] | 60 | printf("\r\n\r\nsysmocom sysmoOCTSIM\r\n"); |
Kévin Redon | 8e53800 | 2019-01-30 11:19:19 +0100 | [diff] [blame] | 61 | while (true) { // main loop |
Harald Welte | 361ed20 | 2019-02-24 21:15:39 +0100 | [diff] [blame] | 62 | 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 Redon | 8e53800 | 2019-01-30 11:19:19 +0100 | [diff] [blame] | 66 | } |
| 67 | } |
Kévin Redon | 69b92d9 | 2019-01-24 16:39:20 +0100 | [diff] [blame] | 68 | } |