diff --git a/drivers/spim.c b/drivers/spim.c new file mode 100644 index 0000000..646876a --- /dev/null +++ b/drivers/spim.c @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2019 ETH Zurich, University of Bologna + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* +* @Author: Alfio Di Mauro +* @Date: 2020-03-23 09:33:29 +* @Last Modified by: Alfio Di Mauro +* @Last Modified time: 2020-03-23 09:38:45 +*/ + +#include "pulp.h" + +#define DEBUG + +static void spim_wait_tx_done(int periph) +{ + + #ifdef DEBUG + int periph_id = periph - ARCHI_SPIM_UART_ID(0); + printf("periph_id = %d\n", periph_id); + #endif + + while (plp_udma_busy(UDMA_SPIM_TX_ADDR(periph - ARCHI_SPIM_UART_ID(0)))) + { + } + + while(plp_uart_tx_busy(periph - ARCHI_UDMA_UART_ID(0))); +} + + +static void spim_wait_rx_done(int periph) +{ + while (plp_udma_busy(UDMA_UART_RX_ADDR(periph - ARCHI_UDMA_UART_ID(0)))) + { + } +} \ No newline at end of file diff --git a/drivers/uart.c b/drivers/uart.c index 088848c..3ec322b 100644 --- a/drivers/uart.c +++ b/drivers/uart.c @@ -16,7 +16,7 @@ #include "pulp.h" - +//#define DEBUG #define UART_BAUDRATE 115200 @@ -39,8 +39,6 @@ static void uart_wait_rx_done(int periph) } } - - static void uart_setup(int channel, int baudrate) { int div = (PERIPH_FREQUENCY + baudrate/2) / baudrate; @@ -48,13 +46,15 @@ static void uart_setup(int channel, int baudrate) plp_uart_setup(channel - ARCHI_UDMA_UART_ID(0), 0, div-1); } - - - int uart_open(int uart_id, int baudrate) { + int periph_id = ARCHI_UDMA_UART_ID(uart_id); - int channel = UDMA_EVENT_ID(periph_id); + int channel = UDMA_EVENT_ID(periph_id); + + #ifdef DEBUG + printf("periph_id = %d, event = %d\n", periph_id,channel); + #endif plp_udma_cg_set(plp_udma_cg_get() | (1<