2016-12-31 12:24:28 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2017 Neo Nenaco <neo@nenaco.de>
|
|
|
|
* Copyright (C) 2017 Koen Zandberg <koen@bergzand.net>
|
|
|
|
*
|
|
|
|
* 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_mrf24j40
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief Implementation of public functions for MRF24J40 drivers
|
|
|
|
*
|
|
|
|
* @author Koen Zandberg <koen@bergzand.net>
|
|
|
|
* @author Neo Nenaco <neo@nenaco.de>
|
|
|
|
*
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "byteorder.h"
|
|
|
|
#include "mrf24j40_registers.h"
|
|
|
|
#include "mrf24j40_internal.h"
|
|
|
|
#include "mrf24j40_netdev.h"
|
2022-08-16 17:28:05 +02:00
|
|
|
#include "ztimer.h"
|
2016-12-31 12:24:28 +01:00
|
|
|
|
2020-10-22 11:34:31 +02:00
|
|
|
#define ENABLE_DEBUG 0
|
2016-12-31 12:24:28 +01:00
|
|
|
#include "debug.h"
|
|
|
|
|
2019-09-13 15:43:58 +02:00
|
|
|
int mrf24j40_reset(mrf24j40_t *dev)
|
2016-12-31 12:24:28 +01:00
|
|
|
{
|
2022-08-16 17:28:05 +02:00
|
|
|
int res = mrf24j40_init_hw(dev);
|
2019-09-13 15:43:58 +02:00
|
|
|
|
|
|
|
if (res < 0) {
|
|
|
|
return res;
|
|
|
|
}
|
2016-12-31 12:24:28 +01:00
|
|
|
|
|
|
|
/* configure Immediate Sleep and Wake-Up mode */
|
|
|
|
mrf24j40_reg_write_short(dev, MRF24J40_REG_WAKECON, MRF24J40_WAKECON_IMMWAKE);
|
|
|
|
|
|
|
|
/* set default options */
|
2017-02-15 13:07:34 +01:00
|
|
|
mrf24j40_set_option(dev, NETDEV_IEEE802154_ACK_REQ, true);
|
2016-12-31 12:24:28 +01:00
|
|
|
mrf24j40_set_option(dev, MRF24J40_OPT_CSMA, true);
|
|
|
|
|
|
|
|
mrf24j40_reset_tasks(dev);
|
|
|
|
DEBUG("mrf24j40_reset(): reset complete.\n");
|
2019-09-13 15:43:58 +02:00
|
|
|
|
|
|
|
return 0;
|
2016-12-31 12:24:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t mrf24j40_tx_load(mrf24j40_t *dev, uint8_t *data, size_t len, size_t offset)
|
|
|
|
{
|
|
|
|
|
2022-08-16 17:28:05 +02:00
|
|
|
DEBUG("[mrf24j40] TX_load\n");
|
2016-12-31 12:24:28 +01:00
|
|
|
|
|
|
|
mrf24j40_tx_normal_fifo_write(dev, MRF24J40_TX_NORMAL_FIFO + offset + 2, data, len);
|
|
|
|
return offset + len;
|
|
|
|
}
|