Skip to content
Commits on Source (4)
......@@ -92,6 +92,10 @@ int beacon_main(int argc, char *argv[])
{
data = argv[1];
}
else if(argc == 1)
{
data = "HELLO 73";
}
else
{
return beacon_usage();
......@@ -138,7 +142,7 @@ int beacon_main(int argc, char *argv[])
printf("write failed, errno=%d\n", errno);
break;
}
sleep(1);
sleep(2);
seqnum += 1;
}
......
/****************************************************************************
* hn70ap/apps/export/leds.h
*
* Copyright (C) 2018 Sebastien Lorquet. All rights reserved.
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef HN70AP_TIMER
#define HN70AP_TIMER
int leds_init(void);
int leds_state(int led, int state);
#endif //HN70AP_TIMER
/****************************************************************************
* hn70ap/apps/export/timer.h
*
* Copyright (C) 2018 Sebastien Lorquet. All rights reserved.
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef HN70AP_TIMER
#define HN70AP_TIMER
int timer_init(void);
#endif //HN70AP_TIMER
......@@ -36,7 +36,7 @@
-include $(TOPDIR)/Make.defs
ASRCS =
CSRCS = eeprom.c
CSRCS = eeprom.c leds.c timer.c
CSRCS += tlv.c crc.c sha256.c hdlc.c
CSRCS += update.c
......
/****************************************************************************
* hn70ap/apps/libhn70ap/timer.c
*
* Copyright (C) 2018 Sebastien Lorquet. All rights reserved.
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <nuttx/leds/userled.h>
#include <hn70ap/timer.h>
int leds_init(void)
{
}
int leds_state(int lednum, bool state)
{
struct userled_s led;
int fd;
int ret;
fd = open("/dev/userleds", O_RDWR);
if(fd<0)
{
fprintf(stderr, "Failed to open LEDS device\n");
return -1;
}
led.ul_led = lednum;
led.ul_on = state;
ret = ioctl(fd, ULEDIOC_SETLED, (unsigned long)&led);
if(ret<0)
{
fprintf(stderr, "Failed to change LED state\n");
return -1;
}
close(fd);
return 0;
}
/****************************************************************************
* hn70ap/apps/libhn70ap/timer.c
*
* Copyright (C) 2018 Sebastien Lorquet. All rights reserved.
* Author: Sebastien Lorquet <sebastien@lorquet.fr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <hn70ap/timer.h>
int timer_init(void)
{
return 0;
}
......@@ -45,6 +45,8 @@
#include <sys/mount.h>
#include <hn70ap/eeprom.h>
#include <hn70ap/timer.h>
#include <hn70ap/leds.h>
#include "sysdaemon_internal.h"
......@@ -79,10 +81,33 @@ int main(int argc, FAR char *argv[])
int sysdaemon_main(int argc, char *argv[])
#endif
{
int ret;
bool defaults;
char call[9];
printf("\nhn70ap system daemon starting\n");
/* Initialize timer thread to help us schedule delays */
ret = timer_init();
if(ret != 0)
{
printf("FATAL: Failed to initialize timers\n");
goto lfail;
}
/* Initialize the leds */
/* Requires timer for blinking */
ret = leds_init();
if(ret != 0)
{
printf("FATAL: Failed to initialize Leds\n");
goto lfail;
}
/* Initialize the EEPROM */
hn70ap_eeconfig_init(&defaults);
if(defaults)
{
......@@ -91,8 +116,15 @@ int sysdaemon_main(int argc, char *argv[])
else
{
hn70ap_eeconfig_getcall("call", call);
call[8] = 0;
printf("Hello %s, best 73's\n", call);
if(call[0] == 0)
{
printf("Callsign not defined yet, please use the config tool\n");
}
else
{
call[8] = 0;
printf("Hello %s, best 73's\n", call);
}
}
hn70ap_mount_storage();
......@@ -108,5 +140,11 @@ int sysdaemon_main(int argc, char *argv[])
printf("Back from nsh, now sleeping forever.\n");
return 0;
lfail:
/* Panic... something could not be initialized
* Try to switch on the red LED
*/
return ERROR;
}
......@@ -18,7 +18,7 @@ be installed via JTAG, and it cannot be upgraded.
OLED screen on the i2c bus. It contains a "fb" example application that will
draw some rectangles on the screen. It also initializes the external memories.
3_updates: This configuration contains the full bootloader and an application
This configuration contains the full bootloader and an application
that can receive a software update from the serial console, then write it to
the bootloader partition, then reboot. After the reboot, the bootloader will
check the validity of the contents in the external flash, and if an update is
......@@ -27,15 +27,54 @@ control to it. You can use the hn70ap_makeupdate utility to build an updater
image to be sent to the board. You can use the hn70ap_serialupdate utility
to transfer the update to the board.
4_ethernet: This configuration will attempt to initialize the external PHY and
3_ethernet: This configuration will attempt to initialize the external PHY and
internal MAC. Then a daemon is started in the background to manage link up/down
events, and start a DHCP request when the link is up.
5_radios: This configuration will attempt to detect and initialize radio modules
connected to the board. It requires a specific branch of the NuttX code that
contains the proper radio driver. More informations about that will be added in
the future.
4_auxradio: This configuration will attempt to detect and initialize the
auxiliary radio module connected to the board. It requires a specific branch
of the NuttX code that contains the proper radio driver, found at:
https://bitbucket.com/slorquet/nuttx/branches/radio
This branch contains development code for the si4463 driver. For the moment
a canned config generated by SiLabs WDS is used, but the goal is to reverse
engineer this tool and allow the user to configure the radio at runtime.
Once development is finished, this driver will be added to the official NuttX
tree, but this event is not expected to happen soon.
Other configurations assume a fully functional board, and are made for real
hn70ap applications, eg router, access point, freedv hotspot.
They will be defined later.
full: This is the latest configuration. It contains code to initialize all
peripherals and boots the hn70ap system daemon that will mount the flash file
system, initialize EEPROM settings, then start the shell.
beacon: This configuration initializes the aux radio and does not have
ethernet enabled. At boot, the beacon app is autostarted, and the code sends
regular data packet on 435 MHz. This is currently used on a secondary board
to test packet reception on my main prototype board.
Applications
============
beacon: A radio beacon that sends data on the air, until the board is stopped.
Future improvements will start a background thread and leave the shell available
so the beacon can be stopped.
config: This tool can be user to manipulate the contents of the configuration
EEPROM. You can list and change settings.
update: A firmware updater that is able to download a new firmware image in the
external flash. Download can be made via a serial port (via the console) or via
tftp (this is faster). Future improvements will support the use of LZF
compression to speed up the data transfer.
sysdaemon: This is the main hn70ap application. It is started on boot in most
useful configuration. The tool initializes some executive framework that will
- init and read the configuration settings in the EEPROM
- mount the external flash SMART filesystem
- start a network monitor to detect cable insertion/removal events, and start
DHCP operations (if enabled) right after the cable is detected.
This diff is collapsed.
......@@ -189,3 +189,9 @@ int board_app_initialize(uintptr_t arg)
return 0;
}
#if !defined(CONFIG_HN70AP_ETHERNET)
void up_netinitialize(void)
{
}
#endif
......@@ -63,50 +63,50 @@ static void *g_phy_arg;
****************************************************************************/
void hn70ap_net_initialize(void)
{
_info("Configuring PHY GPIOs\n");
stm32_configgpio(GPIO_IRQ_ETHERNET);
stm32_configgpio(GPIO_ETHERNET_RST);
g_phy_handler = NULL;
g_phy_arg = NULL;
}
{
_info("Configuring PHY GPIOs\n");
stm32_configgpio(GPIO_IRQ_ETHERNET);
stm32_configgpio(GPIO_ETHERNET_RST);
g_phy_handler = NULL;
g_phy_arg = NULL;
}
/****************************************************************************
* Name: stm32_phy_boardinitialize
****************************************************************************/
int stm32_phy_boardinitialize(int intf)
{
_info("called (intf=%d)\n", intf);
{
_info("called (intf=%d)\n", intf);
_info("PHY reset...\n");
stm32_gpiowrite(GPIO_ETHERNET_RST, 0);
up_mdelay(1);
_info("PHY reset done.\n");
stm32_gpiowrite(GPIO_ETHERNET_RST, 1);
up_mdelay(1);
_info("PHY reset...\n");
stm32_gpiowrite(GPIO_ETHERNET_RST, 0);
up_mdelay(1);
_info("PHY reset done.\n");
stm32_gpiowrite(GPIO_ETHERNET_RST, 1);
up_mdelay(1);
return 0;
}
return 0;
}
/****************************************************************************
* Name: stm32_phy_enable
****************************************************************************/
static void stm32_phy_enable(bool enable)
{
//_info("PHY IRQ enable :%d\n", enable);
if (enable)
{
//_info("PHY IRQ enable :%d\n", enable);
if (enable)
{
stm32_gpiosetevent(GPIO_IRQ_ETHERNET, /*rising*/ FALSE, /*falling*/ TRUE, TRUE,
g_phy_handler, /*arg*/ g_phy_arg);
}
else
{
stm32_gpiosetevent(GPIO_IRQ_ETHERNET, /*rising*/ FALSE, /*falling*/ FALSE, FALSE,
NULL, /*arg*/ NULL);
}
stm32_gpiosetevent(GPIO_IRQ_ETHERNET, /*rising*/ FALSE, /*falling*/ TRUE, TRUE,
g_phy_handler, /*arg*/ g_phy_arg);
}
else
{
stm32_gpiosetevent(GPIO_IRQ_ETHERNET, /*rising*/ FALSE, /*falling*/ FALSE, FALSE,
NULL, /*arg*/ NULL);
}
}
/****************************************************************************
* Name: arch_phy_irq
......@@ -169,37 +169,38 @@ static void stm32_phy_enable(bool enable)
* failure.
*
****************************************************************************/
int arch_phy_irq(FAR const char *intf, xcpt_t handler, void *arg, phy_enable_t *enable)
{
irqstate_t flags;
int arch_phy_irq(FAR const char *intf, xcpt_t handler, void *arg,
FAR phy_enable_t *enable)
{
irqstate_t flags;
/* Disable interrupts until we are done. This guarantees that the
* following operations are atomic.
*/
/* Disable interrupts until we are done. This guarantees that the
* following operations are atomic.
*/
flags = enter_critical_section();
flags = enter_critical_section();
/* Get the old interrupt handler and save the new one */
/* Get the old interrupt handler and save the new one */
g_phy_handler = handler;
g_phy_arg = arg;
g_phy_handler = handler;
g_phy_arg = arg;
if (handler)
{
_info("Attach PHY IRQ\n");
*enable = stm32_phy_enable;
}
else
{
_info("Detach PHY IRQ\n");
*enable = NULL;
}
/* Return with the interrupt disabled in either case */
stm32_phy_enable(FALSE);
leave_critical_section(flags);
return 0;
if (handler)
{
_info("Attach PHY IRQ\n");
*enable = stm32_phy_enable;
}
else
{
_info("Detach PHY IRQ\n");
*enable = NULL;
}
/* Return with the interrupt disabled in either case */
stm32_phy_enable(FALSE);
leave_critical_section(flags);
return 0;
}
......@@ -155,7 +155,7 @@ int hn70ap_genradio_initialize(void)
#if defined(CONFIG_HN70AP_MAINRADIO)
_info("Prepare main radio\n");
si4463_priv_main.gpio_irq = GPIO_IRQ_RADIOMAIN;
radio = RFM26_init(spi4, 0, SI4463_IO0, SI4463_IO1, &si4463_lower_main);
radio = si4463_init(spi4, 0, 30000000, SI4463_IO1, SI4463_IO3, &si4463_lower_main);
if(radio==NULL)
{
_err("Unable to initialize si4463\n");
......