mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-14 04:42:03 +10:00
updated ui added new features
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: debugblinky.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 12 August 2014
|
||||
|
||||
Configures Port E GPIO pins used for debug blinkies, and control lines
|
||||
for SM2000 +12V switching.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2014 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __DEBUGBLINKY__
|
||||
#define __DEBUGBLINKY__
|
||||
|
||||
void init_debug_blinky(void);
|
||||
void txrx_12V(int state);
|
||||
|
||||
#endif
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
memtools.h
|
||||
June 2019
|
||||
|
||||
Tools for anlysing and debugging memory on stm32. See also debug_alloc.h
|
||||
*/
|
||||
|
||||
#ifndef __MEMTOOLS__
|
||||
#define __MEMTOOLS__
|
||||
void memtools_find_unused( int (*printf_func)(const char *fmt, ...) );
|
||||
register char * memtools_sp asm ("sp");
|
||||
void memtools_isnan(float *vec, int n, char *label, int (*printf_func)(const char *fmt, ...));
|
||||
#endif
|
||||
Vendored
+92
@@ -0,0 +1,92 @@
|
||||
#ifndef _MENU_H
|
||||
#define _MENU_H
|
||||
/*!
|
||||
* Callback driven menu handler.
|
||||
*
|
||||
* The following is an implementation of a callback-driven menu system.
|
||||
* It supports arbitrary levels of menus (limited by size of return stack)
|
||||
* and supports arbitrary user events.
|
||||
*
|
||||
* Author Stuart Longland <me@vk4msl.id.au>
|
||||
* Copyright (C) 2015 FreeDV project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License version 2.1,
|
||||
* as published by the Free Software Foundation. This program is
|
||||
* distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this program; if not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define MENU_STACK_SZ 8 /*!< Size of the menu return stack */
|
||||
|
||||
#define MENU_EVT_ENTERED 0 /*!< Menu item has been entered */
|
||||
#define MENU_EVT_RETURNED 1 /*!< We have returned from a submenu */
|
||||
|
||||
/*! Menu state structure */
|
||||
struct menu_t {
|
||||
/*! The last seen menu item */
|
||||
const struct menu_item_t* last;
|
||||
/*! Currently selected item index */
|
||||
uint32_t current;
|
||||
/*! Current menu item stack */
|
||||
struct menu_stack_item_t {
|
||||
const struct menu_item_t* item;
|
||||
uint32_t index;
|
||||
} stack[MENU_STACK_SZ];
|
||||
/*! Present depth of the stack */
|
||||
uint8_t stack_depth;
|
||||
};
|
||||
|
||||
/*! Menu item structure */
|
||||
struct menu_item_t {
|
||||
/*! Morse-code label for the menu item */
|
||||
const char* label;
|
||||
/*! Event callback pointer for menu item */
|
||||
void (*event_cb)(
|
||||
struct menu_t* const menu,
|
||||
uint32_t event);
|
||||
/*! Children of this menu item */
|
||||
const struct menu_item_t** const children;
|
||||
uint32_t num_children;
|
||||
/*! Arbitrary data */
|
||||
union menu_item_data_t {
|
||||
/*! Arbitrary pointer */
|
||||
const void* p;
|
||||
/*! Arbitrary unsigned integer */
|
||||
uintptr_t ui;
|
||||
/*! Arbitrary signed integer */
|
||||
intptr_t si;
|
||||
} data;
|
||||
};
|
||||
|
||||
/*!
|
||||
* Return the Nth item on the stack.
|
||||
*/
|
||||
const struct menu_item_t* const menu_item(
|
||||
const struct menu_t* const menu, uint8_t index);
|
||||
|
||||
/*!
|
||||
* Enter a (sub)-menu.
|
||||
* @retval -1 Stack is full
|
||||
* @retval 0 Success
|
||||
*/
|
||||
int menu_enter(struct menu_t* const menu,
|
||||
const struct menu_item_t* const item);
|
||||
|
||||
/*! Return from a (sub)-menu */
|
||||
void menu_leave(struct menu_t* const menu);
|
||||
|
||||
/*!
|
||||
* Execute the callback for the current item with a user-supplied event.
|
||||
*/
|
||||
void menu_exec(struct menu_t* const menu, uint32_t event);
|
||||
|
||||
#endif
|
||||
Vendored
+65
@@ -0,0 +1,65 @@
|
||||
#ifndef _MORSE_H
|
||||
#define _MORSE_H
|
||||
/*!
|
||||
* Morse code library.
|
||||
*
|
||||
* This implements a state machine for playing back morse code messages.
|
||||
*
|
||||
* Author Stuart Longland <me@vk4msl.id.au>
|
||||
* Copyright (C) 2015 FreeDV project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License version 2.1,
|
||||
* as published by the Free Software Foundation. This program is
|
||||
* distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this program; if not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "sfx.h"
|
||||
|
||||
/*!
|
||||
* Maximum length of a morse symbol, including gaps and termination.
|
||||
* Allowing for 8 actual sub-symbols (dahs and dits), that's up to
|
||||
* 8 gaps between plus a terminator.
|
||||
*/
|
||||
#define MORSE_SYM_LEN (17)
|
||||
|
||||
/*!
|
||||
* Morse code playback state machine
|
||||
*/
|
||||
struct morse_player_t {
|
||||
/*! Symbol being transmitted */
|
||||
struct sfx_note_t sym[MORSE_SYM_LEN];
|
||||
/*!
|
||||
* Pointer to the string being emitted. Playback is finished
|
||||
* when this is NULL.
|
||||
*/
|
||||
const char* msg;
|
||||
/*! Sound effect player state machine */
|
||||
struct sfx_player_t sfx_player;
|
||||
/*! "Dit" period in milliseconds */
|
||||
uint16_t dit_time;
|
||||
/*! Tone frequency */
|
||||
uint16_t freq;
|
||||
};
|
||||
|
||||
/*!
|
||||
* Play a morse code message.
|
||||
* @param morse_player Morse code player state machine
|
||||
* @param msg Message to play back (NULL == stop)
|
||||
*/
|
||||
void morse_play(struct morse_player_t* const morse_player,
|
||||
const char* msg);
|
||||
|
||||
/*!
|
||||
* Retrieve the next sample to be played.
|
||||
*/
|
||||
int16_t morse_next(struct morse_player_t* const morse_player);
|
||||
|
||||
#endif
|
||||
Vendored
+63
@@ -0,0 +1,63 @@
|
||||
#ifndef _SFX_H
|
||||
#define _SFX_H
|
||||
/*!
|
||||
* Sound effect player library.
|
||||
*
|
||||
* This implements a state machine for playing back various monophonic
|
||||
* sound effects such as morse code symbols, clicks and alert tones.
|
||||
*
|
||||
* Author Stuart Longland <me@vk4msl.id.au>
|
||||
* Copyright (C) 2015 FreeDV project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License version 2.1,
|
||||
* as published by the Free Software Foundation. This program is
|
||||
* distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this program; if not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "tone.h"
|
||||
|
||||
/*!
|
||||
* A sound effect "note"
|
||||
*/
|
||||
struct sfx_note_t {
|
||||
/*! Note frequency. 0 == pause */
|
||||
uint16_t freq;
|
||||
/*! Note duration in msec. 0 == end of effect */
|
||||
uint16_t duration;
|
||||
};
|
||||
|
||||
/*!
|
||||
* Sound effect player state machine
|
||||
*/
|
||||
struct sfx_player_t {
|
||||
/*!
|
||||
* Pointer to the current "note". When this is NULL,
|
||||
* playback is complete.
|
||||
*/
|
||||
const struct sfx_note_t* note;
|
||||
/*! Tone generator state machine */
|
||||
struct tone_gen_t tone_gen;
|
||||
};
|
||||
|
||||
/*!
|
||||
* Start playing a particular effect.
|
||||
* @param sfx_player Effect player state machine
|
||||
* @param effect Pointer to sound effect (NULL == stop)
|
||||
*/
|
||||
void sfx_play(struct sfx_player_t* const sfx_player,
|
||||
const struct sfx_note_t* effect);
|
||||
|
||||
/*!
|
||||
* Retrieve the next sample to be played.
|
||||
*/
|
||||
int16_t sfx_next(struct sfx_player_t* const sfx_player);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,86 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: sm1000_leds_switches.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 18 July 2014
|
||||
|
||||
Functions for controlling LEDs and reading switches on SM1000.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2014 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __LEDS_SWITCHES__
|
||||
#define __LEDS_SWITCHES__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void sm1000_leds_switches_init(void);
|
||||
|
||||
#define LED_ON 1 /*!< Turn LED on */
|
||||
#define LED_OFF 0 /*!< Turn LED off */
|
||||
#define LED_INV -1 /*!< Invert LED state */
|
||||
|
||||
void led_pwr(int state);
|
||||
void led_ptt(int state);
|
||||
void led_rt(int state);
|
||||
void led_err(int state);
|
||||
void not_cptt(int state);
|
||||
|
||||
int switch_ptt(void);
|
||||
int switch_select(void);
|
||||
int switch_back(void);
|
||||
int ext_ptt(void);
|
||||
|
||||
#define DEBOUNCE_DELAY 50 /*!< Delay to wait while switch bounces */
|
||||
|
||||
#define SW_STEADY 0 /*!< Switch is in steady-state */
|
||||
#define SW_DEBOUNCE 1 /*!< Switch is being debounced */
|
||||
|
||||
/*! Switch debounce and logic handling */
|
||||
struct switch_t {
|
||||
/*! Debounce/hold timer */
|
||||
uint32_t timer;
|
||||
/*! Current/debounced observed switch state */
|
||||
uint8_t sw;
|
||||
/*! Raw observed switch state (during debounce) */
|
||||
uint8_t raw;
|
||||
/*! Last steady-state switch state */
|
||||
uint8_t last;
|
||||
/*! Debouncer state */
|
||||
uint8_t state;
|
||||
};
|
||||
|
||||
/*! Update the state of a switch */
|
||||
void switch_update(struct switch_t* const sw, uint8_t state);
|
||||
|
||||
/*! Acknowledge the current state of the switch */
|
||||
void switch_ack(struct switch_t* const sw);
|
||||
|
||||
/*! Return how long the switch has been pressed in ticks. */
|
||||
uint32_t switch_pressed(const struct switch_t* const sw);
|
||||
|
||||
/*! Return non-zero if the switch has been released. */
|
||||
int switch_released(const struct switch_t* const sw);
|
||||
|
||||
/*! Count the tick timers on the switches. */
|
||||
void switch_tick(struct switch_t* const sw);
|
||||
|
||||
void ColorfulRingOfDeath(int code);
|
||||
|
||||
#endif
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
#ifndef _SOUNDS_H
|
||||
#define _SOUNDS_H
|
||||
/*!
|
||||
* Sound effect library.
|
||||
*
|
||||
* This provides some sound effects for the SM1000 UI.
|
||||
*
|
||||
* Author Stuart Longland <me@vk4msl.id.au>
|
||||
* Copyright (C) 2015 FreeDV project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License version 2.1,
|
||||
* as published by the Free Software Foundation. This program is
|
||||
* distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this program; if not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "sfx.h"
|
||||
|
||||
/*! Start-up tune / selected tune */
|
||||
extern const struct sfx_note_t sound_startup[];
|
||||
|
||||
/*! Returned tune */
|
||||
extern const struct sfx_note_t sound_returned[];
|
||||
|
||||
/*! Click sound */
|
||||
extern const struct sfx_note_t sound_click[];
|
||||
|
||||
/*! Death march tune */
|
||||
extern const struct sfx_note_t sound_death_march[];
|
||||
|
||||
#endif
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: stm32f4_adc.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 30 May 2014
|
||||
|
||||
Two channel FIFO buffered ADC driver module for STM32F4.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2014 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __STM32F4_ADC__
|
||||
#define __STM32F4_ADC__
|
||||
|
||||
#define ADC_BUF_SZ 320
|
||||
|
||||
/* divisors for various sample rates */
|
||||
|
||||
#define ADC_FS_8KHZ 10500
|
||||
#define ADC_FS_16KHZ 5250
|
||||
#define ADC_FS_48KHZ 1750
|
||||
#define ADC_FS_96KHZ 875
|
||||
|
||||
void adc_open(int fs_divisor, int fifo_sz, short *buf1, short *buf2);
|
||||
int adc1_read(short buf[], int n); /* ADC1 Pin PA1 */
|
||||
int adc2_read(short buf[], int n); /* ADC2 Pin PA2 */
|
||||
int adc1_samps();
|
||||
int adc2_samps();
|
||||
|
||||
#endif
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: stm32f4_dac.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 1 June 2013
|
||||
|
||||
Two channel FIFO buffered DAC driver module for STM32F4.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2013 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __STM32F4_DAC__
|
||||
#define __STM32F4_DAC__
|
||||
|
||||
#define DAC_BUF_SZ 320
|
||||
|
||||
/* divisors for various sample rates */
|
||||
|
||||
#define DAC_FS_8KHZ 10500
|
||||
#define DAC_FS_16KHZ 5250
|
||||
#define DAC_FS_48KHZ 1750
|
||||
#define DAC_FS_96KHZ 875
|
||||
|
||||
void dac_open(int fs_divisor, int fifo_sz, short *buf1, short *buf2);
|
||||
int dac1_write(short buf[], int n, int limit); /* DAC1 pin PA4 */
|
||||
int dac1_free();
|
||||
int dac2_write(short buf[], int n, int limit); /* DAC2 pin PA5 */
|
||||
int dac2_free();
|
||||
|
||||
#endif
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: stm32f4_usart.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: May 2019
|
||||
|
||||
Basic USART tty support for the stm32.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2019 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __STM32F4_USART__
|
||||
#define __STM32F4_USART__
|
||||
|
||||
void usart_init();
|
||||
void usart_puts(const char s[]);
|
||||
int usart_printf(const char *fmt, ...);
|
||||
|
||||
#endif
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: stm32f4_usb_vcp.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 4 Sep 2014
|
||||
|
||||
USB Virtual COM Port (VCP) module.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __STM32F4_USB_VCP__
|
||||
#define __STM32F4_USB_VCP__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void usb_vcp_init(void);
|
||||
|
||||
int VCP_get_char(uint8_t *buf);
|
||||
int VCP_get_string(uint8_t *buf);
|
||||
void VCP_put_char(uint8_t buf);
|
||||
void VCP_send_str(uint8_t* buf);
|
||||
void VCP_send_buffer(uint8_t* buf, int len);
|
||||
|
||||
#endif
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
#ifndef _STM32F4_VROM_H_
|
||||
#define _STM32F4_VROM_H_
|
||||
/*!
|
||||
* STM32F4 Virtual EEPROM driver
|
||||
*
|
||||
* This module implements a crude virtual EEPROM device stored in on-board
|
||||
* flash. The STM32F405 has 4 16kB flash sectors starting at address
|
||||
* 0x80000000, followed by a 64kB sector, then 128kB sectors.
|
||||
*
|
||||
* The Cortex M4 core maps these all to address 0x00000000 when booting
|
||||
* from normal flash, so the first sector is reserved for interrupt
|
||||
* vectors.
|
||||
*
|
||||
* Everything else however is free game, and so we use these smaller
|
||||
* sectors to store our configuration.
|
||||
*
|
||||
* Author Stuart Longland <me@vk4msl.id.au>
|
||||
* Copyright (C) 2015 FreeDV project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License version 2.1,
|
||||
* as published by the Free Software Foundation. This program is
|
||||
* distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this program; if not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
|
||||
/*!
|
||||
* Read data from a virtual EEPROM.
|
||||
* @param rom ROM ID to start reading.
|
||||
* @param offset Address offset into ROM to start reading.
|
||||
* @param size Number of bytes to read from ROM.
|
||||
* @param out Buffer to write ROM content to.
|
||||
* @returns Number of bytes read from ROM.
|
||||
* @retval -ENXIO No valid data found for address.
|
||||
* @retval -ESPIPE Offset past end of ROM.
|
||||
*/
|
||||
int vrom_read(uint8_t rom, uint16_t offset, uint16_t size, void* out);
|
||||
|
||||
/*!
|
||||
* Write data to a virtual EEPROM.
|
||||
* @param rom ROM ID to start writing.
|
||||
* @param offset Address offset into ROM to start writing.
|
||||
* @param size Number of bytes to write to ROM.
|
||||
* @param in Buffer to write ROM content from.
|
||||
* @returns Number of bytes written to ROM.
|
||||
* @retval -EIO Programming failed
|
||||
* @retval -ENOSPC No free blocks available
|
||||
*/
|
||||
int vrom_write(uint8_t rom, uint16_t offset, uint16_t size,
|
||||
const void* in);
|
||||
|
||||
/*!
|
||||
* Erase a virtual EEPROM.
|
||||
* @param rom ROM ID to erase.
|
||||
* @returns Number of bytes written to ROM.
|
||||
* @retval -EIO Programming failed
|
||||
* @retval -ENOSPC No free blocks available
|
||||
*/
|
||||
int vrom_erase(uint8_t rom);
|
||||
|
||||
#endif
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32f4xx_conf.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.0.0
|
||||
* @date 19-September-2011
|
||||
* @brief Library configuration file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
|
||||
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
|
||||
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
|
||||
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32F4xx_CONF_H
|
||||
#define __STM32F4xx_CONF_H
|
||||
|
||||
#if defined (HSE_VALUE)
|
||||
/* Redefine the HSE value; it's equal to 8 MHz on the STM32F4-DISCOVERY Kit */
|
||||
#undef HSE_VALUE
|
||||
#define HSE_VALUE ((uint32_t)8000000)
|
||||
#endif /* HSE_VALUE */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* Uncomment the line below to enable peripheral header file inclusion */
|
||||
#include "stm32f4xx_adc.h"
|
||||
#include "stm32f4xx_can.h"
|
||||
#include "stm32f4xx_crc.h"
|
||||
#include "stm32f4xx_cryp.h"
|
||||
#include "stm32f4xx_dac.h"
|
||||
#include "stm32f4xx_dbgmcu.h"
|
||||
#include "stm32f4xx_dcmi.h"
|
||||
#include "stm32f4xx_dma.h"
|
||||
#include "stm32f4xx_exti.h"
|
||||
#include "stm32f4xx_flash.h"
|
||||
#include "stm32f4xx_fsmc.h"
|
||||
#include "stm32f4xx_hash.h"
|
||||
#include "stm32f4xx_gpio.h"
|
||||
#include "stm32f4xx_i2c.h"
|
||||
#include "stm32f4xx_iwdg.h"
|
||||
#include "stm32f4xx_pwr.h"
|
||||
#include "stm32f4xx_rcc.h"
|
||||
#include "stm32f4xx_rng.h"
|
||||
#include "stm32f4xx_rtc.h"
|
||||
#include "stm32f4xx_sdio.h"
|
||||
#include "stm32f4xx_spi.h"
|
||||
#include "stm32f4xx_syscfg.h"
|
||||
#include "stm32f4xx_tim.h"
|
||||
#include "stm32f4xx_usart.h"
|
||||
#include "stm32f4xx_wwdg.h"
|
||||
#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/* If an external clock source is used, then the value of the following define
|
||||
should be set to the value of the external clock source, else, if no external
|
||||
clock is used, keep this define commented */
|
||||
/*#define I2S_EXTERNAL_CLOCK_VAL 12288000 */ /* Value of the external clock in Hz */
|
||||
|
||||
|
||||
/* Uncomment the line below to expanse the "assert_param" macro in the
|
||||
Standard Peripheral Library drivers code */
|
||||
/* #define USE_FULL_ASSERT 1 */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
#ifdef USE_FULL_ASSERT
|
||||
|
||||
/**
|
||||
* @brief The assert_param macro is used for function's parameters check.
|
||||
* @param expr: If expr is false, it calls assert_failed function
|
||||
* which reports the name of the source file and the source
|
||||
* line number of the call that failed.
|
||||
* If expr is true, it returns no value.
|
||||
* @retval None
|
||||
*/
|
||||
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void assert_failed(uint8_t* file, uint32_t line);
|
||||
#else
|
||||
#define assert_param(expr) ((void)0)
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
#endif /* __STM32F4xx_CONF_H */
|
||||
|
||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||
Vendored
+84
@@ -0,0 +1,84 @@
|
||||
#ifndef _TONE_H
|
||||
#define _TONE_H
|
||||
/*!
|
||||
* Fixed-point tone generator.
|
||||
*
|
||||
* The code here implements a simple fixed-point tone generator that uses
|
||||
* integer arithmetic to generate a sinusoid at a fixed sample rate of
|
||||
* 16kHz.
|
||||
*
|
||||
* To set the initial state of the state machine, you specify a frequency
|
||||
* and duration using tone_reset. The corresponding C file embeds a
|
||||
* sinusoid look-up table. The total number of samples is computed for
|
||||
* the given time and used to initialise 'remain', 'time' is initialised
|
||||
* to 0, and 'step' gives the amount to increment 'time' by each iteration.
|
||||
*
|
||||
* The samples are retrieved by repeatedly calling tone_next. This
|
||||
* advances 'time' and decrements 'remain'. The tone is complete when
|
||||
* 'remain' is zero.
|
||||
*
|
||||
* Author Stuart Longland <me@vk4msl.id.au>
|
||||
* Copyright (C) 2015 FreeDV project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License version 2.1,
|
||||
* as published by the Free Software Foundation. This program is
|
||||
* distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this program; if not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*! Tone sampling rate in Hz. */
|
||||
#define TONE_FS 16000
|
||||
|
||||
/*!
|
||||
* Tone generator state. This holds the current state of the tone
|
||||
* generator in order to decide what sample to release next.
|
||||
*/
|
||||
struct tone_gen_t {
|
||||
/*! Current sample. (Q12) */
|
||||
uint32_t sample;
|
||||
/*!
|
||||
* Time remaining in samples. (integer) Playback is finished
|
||||
* when this reaches zero.
|
||||
*/
|
||||
uint16_t remain;
|
||||
/*!
|
||||
* Subsample step (Q12). This is the number of samples (or part
|
||||
* thereof) to advance "sample". Special case: when zero, sample
|
||||
* is not advanced, silence is generated instead.
|
||||
*/
|
||||
uint16_t step;
|
||||
};
|
||||
|
||||
/*!
|
||||
* Re-set the tone generator.
|
||||
*
|
||||
* @param tone_gen Tone generator to reset.
|
||||
* @param freq Frequency in Hz, 0 = silence.
|
||||
* @param duration Duration in milliseconds. 0 to stop.
|
||||
*/
|
||||
void tone_reset(
|
||||
struct tone_gen_t* const tone_gen,
|
||||
uint16_t freq, uint16_t duration);
|
||||
|
||||
/*!
|
||||
* Retrieve the next sample from the tone generator.
|
||||
* @param tone_gen Tone generator to update.
|
||||
*/
|
||||
int16_t tone_next(
|
||||
struct tone_gen_t* const tone_gen);
|
||||
|
||||
/*!
|
||||
* Retrieve the current time in milliseconds.
|
||||
*/
|
||||
uint32_t tone_msec(const struct tone_gen_t* const tone_gen);
|
||||
|
||||
#endif
|
||||
Vendored
+115
@@ -0,0 +1,115 @@
|
||||
#ifndef _TOT_H
|
||||
#define _TOT_H
|
||||
/*!
|
||||
* Time-out timer.
|
||||
*
|
||||
* This is a simple time-out timer for ensuring a maximum transmission
|
||||
* time is observed. The time-out timer is configured with a total time
|
||||
* in "ticks", which get counted down in an interrupt.
|
||||
*
|
||||
* When the "warning" level is reached, a flag is repeatedly set permit
|
||||
* triggering of LEDs/sounds to warn the user that time is nearly up.
|
||||
*
|
||||
* Upon timeout, a separate flag is set to indicate timeout has taken
|
||||
* place.
|
||||
*
|
||||
* Author Stuart Longland <me@vk4msl.id.au>
|
||||
* Copyright (C) 2015 FreeDV project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License version 2.1,
|
||||
* as published by the Free Software Foundation. This program is
|
||||
* distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this program; if not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*!
|
||||
* Time-out timer state machine
|
||||
*/
|
||||
struct tot_t {
|
||||
/*!
|
||||
* Number of ticks remaining, if non-zero, transmission is
|
||||
* in progress.
|
||||
*/
|
||||
uint32_t remaining;
|
||||
/*!
|
||||
* Number of ticks remaining, before next warning.
|
||||
*/
|
||||
uint32_t warn_remain;
|
||||
/*!
|
||||
* Timeout timer tick period. Used to reset the ticks counter.
|
||||
*/
|
||||
uint32_t tick_period;
|
||||
/*!
|
||||
* Number of ticks between the remaining warnings.
|
||||
*/
|
||||
uint16_t remain_warn_ticks;
|
||||
/*!
|
||||
* Event tick timer. Used to slow down the source timer.
|
||||
*/
|
||||
uint16_t ticks;
|
||||
/*!
|
||||
* Event flags.
|
||||
*/
|
||||
uint16_t event;
|
||||
};
|
||||
|
||||
/*!
|
||||
* Time-out timer has been started.
|
||||
*/
|
||||
#define TOT_EVT_START (1 << 0)
|
||||
|
||||
/*!
|
||||
* Start of warning period reached.
|
||||
*/
|
||||
#define TOT_EVT_WARN (1 << 1)
|
||||
|
||||
/*!
|
||||
* Next warning is due.
|
||||
*/
|
||||
#define TOT_EVT_WARN_NEXT (1 << 2)
|
||||
|
||||
/*!
|
||||
* Time-out reached.
|
||||
*/
|
||||
#define TOT_EVT_TIMEOUT (1 << 3)
|
||||
|
||||
/*!
|
||||
* Timer sequence complete
|
||||
*/
|
||||
#define TOT_EVT_DONE (1 << 4)
|
||||
|
||||
/*!
|
||||
* Reset the time-out timer. This zeroes the counter and event flags.
|
||||
*/
|
||||
void tot_reset(struct tot_t * const tot);
|
||||
|
||||
/*!
|
||||
* Start the time-out timer ticking.
|
||||
*/
|
||||
void tot_start(struct tot_t * const tot, uint32_t tot_ticks,
|
||||
uint16_t warn_ticks);
|
||||
|
||||
/*!
|
||||
* Count a time-out timer tick.
|
||||
*/
|
||||
static inline void tot_tick(struct tot_t * const tot)
|
||||
{
|
||||
if (tot->ticks)
|
||||
tot->ticks--;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Update the time-out timer state.
|
||||
*/
|
||||
void tot_update(struct tot_t * const tot);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user