2020-06-26 10:30:43 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020 Gunar Schorcht
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
|
|
* directory for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup drivers_atwinc15x0
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief RIOT BSP API implementation
|
|
|
|
*
|
|
|
|
* @author Gunar Schorcht <gunar@schorcht.net>
|
|
|
|
*
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2020-10-21 15:56:59 +02:00
|
|
|
#include <assert.h>
|
|
|
|
|
2020-06-26 10:30:43 +02:00
|
|
|
#include "atwinc15x0_internal.h"
|
|
|
|
#include "mutex.h"
|
|
|
|
#include "periph/spi.h"
|
2021-12-11 09:24:54 +01:00
|
|
|
#include "ztimer.h"
|
2020-06-26 10:30:43 +02:00
|
|
|
|
2020-10-22 11:34:31 +02:00
|
|
|
#define ENABLE_DEBUG 0
|
2020-06-26 10:30:43 +02:00
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
void atwinc15x0_isr(void *arg)
|
|
|
|
{
|
|
|
|
(void)arg;
|
|
|
|
if (atwinc15x0->bsp_isr != NULL && atwinc15x0->bsp_irq_enabled) {
|
|
|
|
atwinc15x0->bsp_isr();
|
|
|
|
}
|
|
|
|
atwinc15x0_irq();
|
|
|
|
}
|
|
|
|
|
|
|
|
sint8 nm_bsp_init(void)
|
|
|
|
{
|
|
|
|
assert(atwinc15x0);
|
2020-01-17 12:45:13 +01:00
|
|
|
assert(gpio_is_valid(atwinc15x0->params.reset_pin));
|
|
|
|
assert(gpio_is_valid(atwinc15x0->params.irq_pin));
|
2020-06-26 10:30:43 +02:00
|
|
|
|
|
|
|
gpio_init(atwinc15x0->params.reset_pin, GPIO_OUT);
|
|
|
|
gpio_set(atwinc15x0->params.reset_pin);
|
|
|
|
|
|
|
|
gpio_init_int(atwinc15x0->params.irq_pin, GPIO_IN_PU, GPIO_FALLING,
|
|
|
|
atwinc15x0_isr, NULL);
|
|
|
|
|
2020-01-17 12:45:13 +01:00
|
|
|
if (gpio_is_valid(atwinc15x0->params.chip_en_pin)) {
|
2020-06-26 10:30:43 +02:00
|
|
|
gpio_init(atwinc15x0->params.chip_en_pin, GPIO_OUT);
|
|
|
|
gpio_set(atwinc15x0->params.chip_en_pin);
|
|
|
|
}
|
|
|
|
|
2020-01-17 12:45:13 +01:00
|
|
|
if (gpio_is_valid(atwinc15x0->params.wake_pin)) {
|
2020-06-26 10:30:43 +02:00
|
|
|
gpio_init(atwinc15x0->params.wake_pin, GPIO_OUT);
|
|
|
|
gpio_set(atwinc15x0->params.wake_pin);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
sint8 nm_bsp_deinit(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nm_bsp_reset(void)
|
|
|
|
{
|
|
|
|
assert(atwinc15x0);
|
|
|
|
gpio_clear(atwinc15x0->params.reset_pin);
|
|
|
|
nm_bsp_sleep(100);
|
|
|
|
gpio_set(atwinc15x0->params.reset_pin);
|
|
|
|
nm_bsp_sleep(100);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nm_bsp_sleep(uint32 u32TimeMsec)
|
|
|
|
{
|
2021-12-11 09:24:54 +01:00
|
|
|
ztimer_sleep(ZTIMER_MSEC, u32TimeMsec);
|
2020-06-26 10:30:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void nm_bsp_register_isr(tpfNmBspIsr pfIsr)
|
|
|
|
{
|
|
|
|
assert(atwinc15x0);
|
|
|
|
|
2020-07-21 23:16:06 +02:00
|
|
|
DEBUG("%s %p\n", __func__, (void *)(uintptr_t)pfIsr);
|
2020-06-26 10:30:43 +02:00
|
|
|
|
|
|
|
atwinc15x0->bsp_isr = pfIsr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nm_bsp_interrupt_ctrl(uint8 u8Enable)
|
|
|
|
{
|
|
|
|
assert(atwinc15x0);
|
|
|
|
|
|
|
|
DEBUG("%s %u\n", __func__, u8Enable);
|
|
|
|
|
|
|
|
atwinc15x0->bsp_irq_enabled = u8Enable;
|
|
|
|
}
|