Compare commits
10 Commits
b69684b8b7
...
75f5ef8e07
Author | SHA1 | Date |
---|---|---|
Paul Warren | 75f5ef8e07 | |
Paul Warren | 0de5e32b0e | |
Paul Warren | e32fdbd61b | |
Paul Warren | e1a17c0d3e | |
Paul Warren | 46bdb983b3 | |
Paul Warren | 3a473c183c | |
Paul Warren | babcaa037f | |
Paul Warren | 78f16d341d | |
Paul Warren | 751c4527b6 | |
Paul Warren | 44aa478637 |
|
@ -76,4 +76,5 @@ Hardware/Enclosure/~$paddle_Mirrored.SLDPRT
|
|||
|
||||
|
||||
*.o
|
||||
*.lst
|
||||
*.lst
|
||||
*~
|
|
@ -3,19 +3,19 @@
|
|||
|
||||
|
||||
#ifdef PSDR2
|
||||
#include "stm32f4xx.h"
|
||||
#include "stm32f4xx.h"
|
||||
#include "stm32f429xx.h"
|
||||
#endif
|
||||
|
||||
|
||||
//#ifdef PSDR257
|
||||
#include "stm32f7xx.h"
|
||||
#include "stm32f7xx.h"
|
||||
#include "stm32f746xx.h"
|
||||
//#include "stm32f7xx_hal.h"
|
||||
//#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <Adafruit_ILI9340.h>
|
||||
//#include <Adafruit_SSD1306.h>
|
||||
|
||||
#define swap(a, b) { int16_t t = a; a = b; b = t; }
|
||||
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
//
|
||||
// This file is part of the GNU ARM Eclipse distribution.
|
||||
// Copyright (c) 2014 Liviu Ionescu.
|
||||
//
|
||||
|
||||
#ifndef BLINKLED_H_
|
||||
#define BLINKLED_H_
|
||||
|
||||
#include "stm32f7xx.h"
|
||||
#include "stm32f7xx_hal_gpio.h"
|
||||
//#include "spi.h"
|
||||
//#include "hal.h"
|
||||
|
||||
// ----- LED definitions ------------------------------------------------------
|
||||
|
||||
// Adjust these definitions for your own board.
|
||||
|
||||
|
||||
// Ports numbers are: PA=0, PB=1, PC=2, PD=3, PE=4, PF=5, PG=6, PH=7, PI=8.
|
||||
|
||||
#if defined(STM32F746xx)
|
||||
|
||||
#if defined(STM32F746_EVAL)
|
||||
|
||||
//#warning "Assume a STM32F746G-EVAL board, PF12 & PB7, active low."
|
||||
|
||||
#define BLINK_PORT_NUMBER (5)
|
||||
#define BLINK_PIN_NUMBER (12)
|
||||
|
||||
#define BLINK_PORT_NUMBER_RED (1)
|
||||
#define BLINK_PIN_NUMBER_RED (7)
|
||||
|
||||
#define BLINK_ACTIVE_LOW (1)
|
||||
|
||||
#else
|
||||
|
||||
//#warning "Assume a STM32F746G-DISCO board, PI1, active high."
|
||||
|
||||
// STM32F746-DISCO definitions (the GREEN led, I1, active high)
|
||||
|
||||
#define BLINK_PORT_NUMBER (4)
|
||||
#define BLINK_PIN_NUMBER (13)
|
||||
#define BLINK_ACTIVE_LOW (0)
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
//#warning "Unknown board, assume PA5, active high."
|
||||
|
||||
#define BLINK_PORT_NUMBER (0)
|
||||
#define BLINK_PIN_NUMBER (5)
|
||||
#define BLINK_ACTIVE_LOW (0)
|
||||
|
||||
#endif
|
||||
|
||||
#define BLINK_GPIOx(_N) ((GPIO_TypeDef *)(GPIOA_BASE + (GPIOB_BASE-GPIOA_BASE)*(_N)))
|
||||
#define BLINK_PIN_MASK(_N) (1 << (_N))
|
||||
#define BLINK_RCC_MASKx(_N) (RCC_AHB1ENR_GPIOAEN << (_N))
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
extern
|
||||
void
|
||||
blink_led_init(void);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
inline void
|
||||
blink_led_on(void);
|
||||
|
||||
inline void
|
||||
blink_led_off(void);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
inline void
|
||||
__attribute__((always_inline))
|
||||
blink_led_on(void)
|
||||
{
|
||||
#if (BLINK_ACTIVE_LOW)
|
||||
HAL_GPIO_WritePin(BLINK_GPIOx(BLINK_PORT_NUMBER),
|
||||
BLINK_PIN_MASK(BLINK_PIN_NUMBER), GPIO_PIN_RESET);
|
||||
#else
|
||||
HAL_GPIO_WritePin(BLINK_GPIOx(BLINK_PORT_NUMBER),
|
||||
BLINK_PIN_MASK(BLINK_PIN_NUMBER), GPIO_PIN_SET);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void
|
||||
__attribute__((always_inline))
|
||||
blink_led_off(void)
|
||||
{
|
||||
#if (BLINK_ACTIVE_LOW)
|
||||
HAL_GPIO_WritePin(BLINK_GPIOx(BLINK_PORT_NUMBER),
|
||||
BLINK_PIN_MASK(BLINK_PIN_NUMBER), GPIO_PIN_SET);
|
||||
#else
|
||||
HAL_GPIO_WritePin(BLINK_GPIOx(BLINK_PORT_NUMBER),
|
||||
BLINK_PIN_MASK(BLINK_PIN_NUMBER), GPIO_PIN_RESET);
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#endif // BLINKLED_H_
|
|
@ -0,0 +1,30 @@
|
|||
//
|
||||
// This file is part of the GNU ARM Eclipse Plug-ins project.
|
||||
// Copyright (c) 2014 Liviu Ionescu.
|
||||
//
|
||||
|
||||
#ifndef TIMER_H_
|
||||
#define TIMER_H_
|
||||
|
||||
#include "stm32f7xx_hal.h"
|
||||
//#include "cmsis_device.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define TIMER_FREQUENCY_HZ (1000u)
|
||||
|
||||
typedef uint32_t timer_ticks_t;
|
||||
|
||||
extern volatile timer_ticks_t timer_delayCount;
|
||||
|
||||
extern void
|
||||
timer_start (void);
|
||||
|
||||
extern void
|
||||
timer_sleep (timer_ticks_t ticks);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#endif // TIMER_H_
|
||||
|
||||
void timer_tick (void);
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
TinyGPS - a small GPS library for Arduino providing basic NMEA parsing
|
||||
Based on work by and "distance_to" and "course_to" courtesy of Maarten Lamers.
|
||||
Suggestion to add satellites(), course_to(), and cardinal(), by Matt Monson.
|
||||
Precision improvements suggested by Wayne Holder.
|
||||
Copyright (C) 2008-2013 Mikal Hart
|
||||
All rights reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef TinyGPS_h
|
||||
#define TinyGPS_h
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define _GPS_VERSION 13 // software version of this library
|
||||
#define _GPS_MPH_PER_KNOT 1.15077945
|
||||
#define _GPS_MPS_PER_KNOT 0.51444444
|
||||
#define _GPS_KMPH_PER_KNOT 1.852
|
||||
#define _GPS_MILES_PER_METER 0.00062137112
|
||||
#define _GPS_KM_PER_METER 0.001
|
||||
// #define _GPS_NO_STATS
|
||||
|
||||
//class TinyGPS
|
||||
//{
|
||||
//public:
|
||||
enum {
|
||||
GPS_INVALID_AGE = 0xFFFFFFFF, GPS_INVALID_ANGLE = 999999999,
|
||||
GPS_INVALID_ALTITUDE = 999999999, GPS_INVALID_DATE = 0,
|
||||
GPS_INVALID_TIME = 0xFFFFFFFF, GPS_INVALID_SPEED = 999999999,
|
||||
GPS_INVALID_FIX_TIME = 0xFFFFFFFF, GPS_INVALID_SATELLITES = 0xFF,
|
||||
GPS_INVALID_HDOP = 0xFFFFFFFF
|
||||
};
|
||||
|
||||
static const float GPS_INVALID_F_ANGLE, GPS_INVALID_F_ALTITUDE, GPS_INVALID_F_SPEED;
|
||||
|
||||
void TinyGPS_init();
|
||||
bool TinyGPS_encode(char c); // process one character received from GPS
|
||||
//TinyGPS &operator << (char c) {encode(c); return *this;}
|
||||
|
||||
// lat/long in MILLIONTHs of a degree and age of fix in milliseconds
|
||||
// (note: versions 12 and earlier gave lat/long in 100,000ths of a degree.
|
||||
void TinyGPS_get_position(long *latitude, long *longitude, unsigned long *fix_age); //Used to end: unsigned long *fix_age = 0);
|
||||
|
||||
// date as ddmmyy, time as hhmmsscc, and age in milliseconds
|
||||
void TinyGPS_get_datetime(unsigned long *date, unsigned long *time, unsigned long *age); //Used to end: unsigned long *age = 0);
|
||||
|
||||
// signed altitude in centimeters (from GPGGA sentence)
|
||||
inline long TinyGPS_altitude();
|
||||
|
||||
// course in last full GPRMC sentence in 100th of a degree
|
||||
inline unsigned long TinyGPS_course();
|
||||
|
||||
// speed in last full GPRMC sentence in 100ths of a knot
|
||||
inline unsigned long TinyGPS_speed();
|
||||
|
||||
// satellites used in last full GPGGA sentence
|
||||
inline unsigned short TinyGPS_satellites();
|
||||
|
||||
// horizontal dilution of precision in 100ths
|
||||
inline unsigned long TinyGPS_hdop();
|
||||
|
||||
int TinyGPS_hasFix();
|
||||
|
||||
void TinyGPS_f_get_position(float *latitude, float *longitude, unsigned long *fix_age); //Used to end: unsigned long *fix_age = 0);
|
||||
void TinyGPS_crack_datetime(int *year, unsigned char *month, unsigned char *day, //the unsigned chars were bytes before
|
||||
unsigned char *hour, unsigned char *minute, unsigned char *second, unsigned char *hundredths, unsigned long *fix_age); //Used to end: byte *hundredths = 0, unsigned long *fix_age = 0);
|
||||
float f_altitude();
|
||||
float f_course();
|
||||
float f_speed_knots();
|
||||
float f_speed_mph();
|
||||
float f_speed_mps();
|
||||
float f_speed_kmph();
|
||||
|
||||
int TinyGPS_library_version();
|
||||
|
||||
float TinyGPS_distance_between (long lat1, long long1, long lat2, long long2);
|
||||
// expects lat/long params in MILLIONTHs of decimal degree
|
||||
float TinyGPS_course_to (float lat1, float long1, float lat2, float long2);
|
||||
const char *TinyGPS_cardinal(float course);
|
||||
|
||||
int TinyGPS_feedGps();
|
||||
|
||||
#ifndef _GPS_NO_STATS
|
||||
void TinyGPS_stats(unsigned long *chars, unsigned short *good_sentences, unsigned short *failed_cs);
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -66,7 +66,7 @@ extern ADC_HandleTypeDef hadc2;
|
|||
extern ADC_HandleTypeDef hadc3;
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
uint8_t wrongThings;
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
extern void _Error_Handler(char *, int);
|
||||
|
@ -76,7 +76,15 @@ void MX_ADC2_Init(void);
|
|||
void MX_ADC3_Init(void);
|
||||
|
||||
/* USER CODE BEGIN Prototypes */
|
||||
__IO uint16_t uhADCxConvertedValue1;
|
||||
__IO uint16_t uhADCxConvertedValue2;
|
||||
__IO uint16_t uhADCxConvertedValue3;
|
||||
uint8_t adcConfigured;
|
||||
uint16_t sampleIndex;
|
||||
|
||||
volatile uint8_t sampleRun;
|
||||
void adcGetConversion(void);
|
||||
void adcStartConversion(void);
|
||||
/* USER CODE END Prototypes */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef DDS_H_
|
||||
#define DDS_H_
|
||||
|
||||
#include "hal.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* DDS_H_ */
|
|
@ -55,7 +55,7 @@
|
|||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f7xx_hal.h"
|
||||
#include "stm32f7xx.h"
|
||||
#include "main.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
|
||||
|
||||
/*
|
||||
* BMP image data converted from 24bpp
|
||||
* to RGB565
|
||||
*/
|
||||
|
||||
#define COLOR_BPP 16
|
||||
#define COLOR_STORAGE_SIZE 2
|
||||
#define BMPWIDTH 69;
|
||||
#define BMPHEIGHT 33;
|
||||
|
||||
extern unsigned short psdrLogo[];
|
||||
extern unsigned short bitmapMode[];
|
||||
extern unsigned short bitmapLSB[];
|
||||
extern unsigned short bitmapUSB[];
|
||||
extern unsigned short bitmapAM[];
|
||||
extern unsigned short bitmapPeriod[];
|
||||
extern unsigned short bitmapOne[];
|
||||
extern unsigned short bitmapTwo[];
|
||||
extern unsigned short bitmapThree[];
|
||||
extern unsigned short bitmapFour[];
|
||||
extern unsigned short bitmapFive[];
|
||||
extern unsigned short bitmapSix[];
|
||||
extern unsigned short bitmapSeven[];
|
||||
extern unsigned short bitmapEight[];
|
||||
extern unsigned short bitmapNine[];
|
||||
extern unsigned short bitmapZero[];
|
||||
extern unsigned short bitmapIronGradient[];
|
||||
extern unsigned short bitmapWebSdrGradient[];
|
||||
extern unsigned short bitmapFilter[];
|
||||
extern unsigned short bitmapHadLogo[];
|
||||
extern unsigned short bitmapSMeter[];
|
||||
extern unsigned short bitmapOff[];
|
||||
|
||||
extern unsigned short oneSmall[];
|
||||
extern unsigned short twoSmall[];
|
||||
extern unsigned short threeSmall[];
|
||||
extern unsigned short fourSmall[];
|
||||
extern unsigned short fiveSmall[];
|
||||
extern unsigned short sixSmall[];
|
||||
extern unsigned short sevenSmall[];
|
||||
extern unsigned short eightSmall[];
|
||||
extern unsigned short nineSmall[];
|
||||
extern unsigned short zeroSmall[];
|
||||
extern unsigned short hyphenSmall[];
|
||||
extern unsigned short tildeSmall[];
|
|
@ -1,89 +1,135 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file : main.h
|
||||
* @brief : Header for main.c file.
|
||||
* This file contains the common defines of the application.
|
||||
******************************************************************************
|
||||
* This notice applies to any and all portions of this file
|
||||
* that are not between comment pairs USER CODE BEGIN and
|
||||
* USER CODE END. Other portions of this file, whether
|
||||
* inserted by the user or by software development tools
|
||||
* are owned by their respective copyright owners.
|
||||
*
|
||||
* Copyright (c) 2018 STMicroelectronics International N.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted, provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistribution 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 of STMicroelectronics nor the names of other
|
||||
* contributors to this software may be used to endorse or promote products
|
||||
* derived from this software without specific written permission.
|
||||
* 4. This software, including modifications and/or derivative works of this
|
||||
* software, must execute solely and exclusively on microcontroller or
|
||||
* microprocessor devices manufactured by or for STMicroelectronics.
|
||||
* 5. Redistribution and use of this software other than as permitted under
|
||||
* this license is void and will automatically terminate your rights under
|
||||
* this license.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
|
||||
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||
* SHALL STMICROELECTRONICS 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __MAIN_H__
|
||||
#define __MAIN_H__
|
||||
//#define PSDR1 1
|
||||
//#define PSDR2 2
|
||||
//#define PSDR25 3
|
||||
#define PSDR257 4
|
||||
//#define ARM_MATH_CM7
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f7xx_hal.h"
|
||||
//#define PSDR_BOARD PSDR2
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
#ifdef PSDR1
|
||||
#define STM32F415xx
|
||||
#define HSE_VALUE=8000000 //did I do this right? Both of these were defined in the progect settings before in the several preprocessors
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
|
||||
#define TESTTEST_Pin GPIO_PIN_2
|
||||
#define TESTTEST_GPIO_Port GPIOC
|
||||
|
||||
/* ########################## Assert Selection ############################## */
|
||||
/**
|
||||
* @brief Uncomment the line below to expanse the "assert_param" macro in the
|
||||
* HAL drivers code
|
||||
*/
|
||||
/* #define USE_FULL_ASSERT 1U */
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void _Error_Handler(char *, int);
|
||||
|
||||
#define Error_Handler() _Error_Handler(__FILE__, __LINE__)
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
//#include "stm32f415xx.h"
|
||||
#endif
|
||||
|
||||
#endif /* __MAIN_H__ */
|
||||
#ifdef PSDR2
|
||||
//#define HSE_VALUE 24000000
|
||||
|
||||
#include "stm32f429xx.h"
|
||||
#include "stm32f4xx.h"
|
||||
#include "stm32f4xx_hal_conf.h"
|
||||
#include "stm32f4xx_hal.h"
|
||||
#include "stm32f4xx_hal_gpio.h"
|
||||
#include "stm32f4xx_hal_def.h"
|
||||
#include "stm32f4xx_it.h"
|
||||
#include "stm32f4xx_hal_tim.h"
|
||||
#include "stm32f4xx_hal_cortex.h"
|
||||
#include "stm32f4xx_hal_dma.h"
|
||||
#include "stm32f4xx_hal_dac.h"
|
||||
#include "stm32f4xx_hal_uart.h"
|
||||
#include "stm32f4xx_hal_usart.h"
|
||||
#include "stm32f4xx_hal_pwr.h"
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef PSDR257
|
||||
//#define HSE_VALUE 26000000
|
||||
//#define ARM_MATH_CM7
|
||||
//#include "stm32f756xx.h"
|
||||
//#define ART_ACCLERATOR_ENABLE 1
|
||||
|
||||
#include "stm32f7xx.h"
|
||||
//#include "stm32f7xx_hal.h"
|
||||
//#include "stm32f7xx_hal_conf.h"
|
||||
//#include "stm32f7xx_hal.h"
|
||||
//#include "stm32f7xx_hal_gpio.h"
|
||||
//#include "stm32f7xx_hal_def.h"
|
||||
//#include "stm32f7xx_it.h"
|
||||
//#include "stm32f7xx_hal_tim.h"
|
||||
//#include "stm32f7xx_hal_cortex.h"
|
||||
//#include "stm32f7xx_hal_dma.h"
|
||||
//#include "stm32f7xx_hal_dac.h"
|
||||
//#include "stm32f7xx_hal_uart.h"
|
||||
//#include "stm32f7xx_hal_usart.h"
|
||||
//#include "stm32f7xx_hal_i2c.h"
|
||||
//#include "stm32f7xx_hal_i2c_ex.h"
|
||||
//#include "stm32f7xx_hal_tim_ex.h"
|
||||
//#include "stm32f7xx_hal_pwr.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include "arm_math.h"
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "stddef.h"
|
||||
#include "diag/Trace.h"
|
||||
#include "dds.h"
|
||||
#include "Timer.h"
|
||||
#include "BlinkLed.h"
|
||||
#include "Adafruit_GFX.h"
|
||||
#include "Adafruit_ILI9340.h"
|
||||
#include "string.h"
|
||||
#include "images.h"
|
||||
#include "frequency_control.h"
|
||||
//#include "usart.h"
|
||||
|
||||
//TIM_HandleTypeDef TimHandle;
|
||||
//TIM_HandleTypeDef TimHandle4;
|
||||
|
||||
#define MASKRED 0b1111100000000000
|
||||
#define MASKGREEN 0b0000011111100000
|
||||
#define MASKBLUE 0b0000000000011111
|
||||
#define MASKYELLOW 0b1111111111100000
|
||||
#define MASKTEAL 0b0000011111111111
|
||||
#define MASKWHITE 0b1111111111111111
|
||||
#define MASKBLACK 0b0000000000000000
|
||||
|
||||
|
||||
|
||||
/* DMA */
|
||||
|
||||
//static DMA_HandleTypeDef hdma_tx;
|
||||
//static DMA_HandleTypeDef hdma_rx;
|
||||
|
||||
/* Definition for SPIx's DMA */
|
||||
#define SPIx_TX_DMA_CHANNEL DMA_CHANNEL_3
|
||||
#define SPIx_TX_DMA_STREAM DMA2_Stream3
|
||||
#define SPIx_RX_DMA_CHANNEL DMA_CHANNEL_3
|
||||
#define SPIx_RX_DMA_STREAM DMA2_Stream2
|
||||
|
||||
/* Definition for SPIx's NVIC */
|
||||
#define SPIx_DMA_TX_IRQn DMA2_Stream3_IRQn
|
||||
#define SPIx_DMA_RX_IRQn DMA2_Stream2_IRQn
|
||||
#define SPIx_DMA_TX_IRQHandler DMA2_Stream3_IRQHandler
|
||||
#define SPIx_DMA_RX_IRQHandler DMA2_Stream2_IRQHandler
|
||||
|
||||
//SPI_HandleTypeDef SpiHandle;
|
||||
//UART_HandleTypeDef UartHandle;
|
||||
|
||||
|
||||
/* main.c functions */
|
||||
|
||||
void drawNumber(char c, uint16_t x, uint16_t y, uint16_t tintMask);
|
||||
void drawNumberSmall(char c, uint16_t x, uint16_t y, uint16_t tintMask);
|
||||
void TIM_Try(void);
|
||||
void TIM3_IRQHandler(void);
|
||||
void TIM4_IRQHandler(void);
|
||||
void initDac1();
|
||||
void dac1SetValue(uint16_t value);
|
||||
void dac2SetValue(uint16_t value);
|
||||
void drawSMeter(void);
|
||||
void updateMenu();
|
||||
void updateDisplay(uint8_t force);
|
||||
void drawWaterfall(void);
|
||||
void Tick(void);
|
||||
void updateVfo(void);
|
||||
void zeroSampleBank(float *samples);
|
||||
|
||||
void shutDown(void);
|
||||
|
||||
|
||||
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f7xx_hal.h"
|
||||
//#include "stm32f7xx_hal.h"
|
||||
#include "main.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
|
|
@ -54,8 +54,7 @@
|
|||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f7xx_hal.h"
|
||||
#include "main.h"
|
||||
#include "stm32f7xx.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ BUILD_DIR = build
|
|||
C_SOURCES = \
|
||||
Src/Adafruit_GFX.c \
|
||||
Src/Adafruit_ILI9340.c \
|
||||
Src/BlinkLed.c \
|
||||
Src/main.c \
|
||||
Src/gpio.c \
|
||||
Src/adc.c \
|
||||
|
@ -61,6 +62,8 @@ Src/usb_otg.c \
|
|||
Src/stm32f7xx_it.c \
|
||||
Src/stm32f7xx_hal_msp.c \
|
||||
Src/stm32f7xx_hal_timebase_TIM.c \
|
||||
Src/Trace.c \
|
||||
Src/trace_impl.c \
|
||||
Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_adc.c \
|
||||
Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_adc_ex.c \
|
||||
Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_cortex.c \
|
||||
|
@ -218,10 +221,10 @@ $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
|
|||
|
||||
$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
|
||||
$(HEX) $< $@
|
||||
|
||||
|
||||
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
|
||||
$(BIN) $< $@
|
||||
|
||||
$(BIN) $< $@
|
||||
|
||||
$(BUILD_DIR):
|
||||
-mkdir $@
|
||||
|
||||
|
@ -230,7 +233,7 @@ $(BUILD_DIR):
|
|||
#######################################
|
||||
clean:
|
||||
-rm -fR $(BUILD_DIR)
|
||||
|
||||
|
||||
#######################################
|
||||
# dependencies
|
||||
#######################################
|
||||
|
|
|
@ -45,7 +45,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
//#include "stm32f10x.h"
|
||||
//#include <stm32f415xx.h>
|
||||
#ifdef PSDR2
|
||||
#include "stm32f429xx.h"
|
||||
// #include "stm32f429xx.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -238,12 +238,12 @@ void Adafruit_GFX_drawFastHLine(int16_t x, int16_t y,
|
|||
}
|
||||
|
||||
void Adafruit_GFX_fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
||||
uint16_t color) {
|
||||
uint16_t color) {
|
||||
// Update in subclasses if desired!
|
||||
int16_t i;
|
||||
// for ( i=x; i<x+w; i++) {
|
||||
// Adafruit_ILI9340_drawFastVLine(i, y, h, color);
|
||||
// }
|
||||
// int16_t i;
|
||||
// for ( i=x; i<x+w; i++) {
|
||||
// Adafruit_ILI9340_drawFastVLine(i, y, h, color);
|
||||
// }
|
||||
|
||||
Adafruit_ILI9340_fillRect(x, y, w, h, color);
|
||||
}
|
||||
|
@ -382,8 +382,8 @@ void Adafruit_GFX_drawBitmap(int16_t x, int16_t y,
|
|||
|
||||
|
||||
//#include "Adafruit_ILI9340.h"
|
||||
#include "spi.h"
|
||||
#include "hal.h"
|
||||
//#include "spi.h"
|
||||
//#include "hal.h"
|
||||
|
||||
|
||||
//#ifdef PSDR2
|
||||
|
@ -391,8 +391,10 @@ void Adafruit_GFX_drawBitmap(int16_t x, int16_t y,
|
|||
//#endif
|
||||
|
||||
//#ifdef PSDR257
|
||||
//#include "stm32f7xx_hal_spi.h"
|
||||
//#include "stm32f7xx_hal.h"
|
||||
//#endif
|
||||
#include "spi.h"
|
||||
|
||||
void Adafruit_GFX_drawColorBitmap(int16_t x, int16_t y, uint16_t *bitmap, int16_t w, int16_t h, uint16_t tintMask)
|
||||
{
|
||||
int16_t i; //, j, bmIndex;
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
//
|
||||
// This file is part of the GNU ARM Eclipse distribution.
|
||||
// Copyright (c) 2014 Liviu Ionescu.
|
||||
//
|
||||
|
||||
#include "BlinkLed.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
blink_led_init()
|
||||
{
|
||||
// Enable GPIO Peripheral clock
|
||||
RCC->AHB1ENR |= BLINK_RCC_MASKx(BLINK_PORT_NUMBER);
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
// Configure pin in output push/pull mode
|
||||
GPIO_InitStructure.Pin = BLINK_PIN_MASK(BLINK_PIN_NUMBER);
|
||||
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStructure.Speed = GPIO_SPEED_FAST;
|
||||
GPIO_InitStructure.Pull = GPIO_PULLUP;
|
||||
HAL_GPIO_Init(BLINK_GPIOx(BLINK_PORT_NUMBER), &GPIO_InitStructure);
|
||||
|
||||
// Start with led turned off
|
||||
blink_led_off();
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
|
@ -4,7 +4,7 @@
|
|||
//
|
||||
|
||||
#include "Timer.h"
|
||||
#include "cortexm/ExceptionHandlers.h"
|
||||
//#include "cortexm/ExceptionHandlers.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -24,7 +24,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "TinyGPS.h"
|
||||
#include <math.h>
|
||||
//#include <trig.h>
|
||||
//#include <hal.h>
|
||||
#include <hal.h>
|
||||
//#include "stm32f7xx_hal.h"
|
||||
|
||||
#define _GPRMC_TERM "GPRMC"
|
||||
#define _GPGGA_TERM "GPGGA"
|
||||
|
@ -450,13 +451,13 @@ float TinyGPS_distance_between (long lat1_, long long1_, long lat2_, long long2_
|
|||
float long1 = long1_ / 1000000.0;
|
||||
float lat2 = lat2_ / 1000000.0;
|
||||
float long2 = long2_ / 1000000.0;
|
||||
float delta = (long1-long2) * PI/180.0;
|
||||
float delta = (long1-long2) * M_PI /180.0;
|
||||
float sdlong = sin(delta);
|
||||
float cdlong = cos(delta);
|
||||
//lat1 = radians(lat1);
|
||||
//lat2 = radians(lat2);
|
||||
lat1 = (lat1) * PI/180.0;
|
||||
lat2 = (lat2) * PI/180.0;
|
||||
lat1 = (lat1) * M_PI / 180.0;
|
||||
lat2 = (lat2) * M_PI / 180.0;
|
||||
float slat1 = sin(lat1);
|
||||
float clat1 = cos(lat1);
|
||||
float slat2 = sin(lat2);
|
||||
|
@ -479,11 +480,11 @@ float TinyGPS_course_to (float lat1, float long1, float lat2, float long2)
|
|||
// Because Earth is no exact sphere, calculated course may be off by a tiny fraction.
|
||||
// Courtesy of Maarten Lamers
|
||||
//float dlon = radians(long2-long1);
|
||||
float dlon = (long2-long1) * PI/180.0;
|
||||
float dlon = (long2-long1) * M_PI /180.0;
|
||||
//lat1 = radians(lat1);
|
||||
//lat2 = radians(lat2);
|
||||
lat1 = (lat1) * PI/180.0;
|
||||
lat2 = (lat2) * PI/180.0;
|
||||
lat1 = (lat1) * M_PI /180.0;
|
||||
lat2 = (lat2) * M_PI /180.0;
|
||||
float a1 = sin(dlon) * cos(lat2);
|
||||
float a2 = sin(lat1) * cos(lat2) * cos(dlon);
|
||||
a2 = cos(lat1) * sin(lat2) - a2;
|
||||
|
@ -493,7 +494,7 @@ float TinyGPS_course_to (float lat1, float long1, float lat2, float long2)
|
|||
a2 += TWO_PI;
|
||||
}
|
||||
//return degrees(a2);
|
||||
return (a2) * 180.0 / PI;
|
||||
return (a2) * 180.0 / M_PI;
|
||||
}
|
||||
|
||||
const char *TinyGPS_cardinal (float course)
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
//
|
||||
// This file is part of the µOS++ III distribution.
|
||||
// Copyright (c) 2014 Liviu Ionescu.
|
||||
//
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(TRACE)
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "diag/Trace.h"
|
||||
#include "string.h"
|
||||
|
||||
#ifndef OS_INTEGER_TRACE_PRINTF_TMP_ARRAY_SIZE
|
||||
#define OS_INTEGER_TRACE_PRINTF_TMP_ARRAY_SIZE (128)
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
trace_printf(const char* format, ...)
|
||||
{
|
||||
int ret;
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, format);
|
||||
|
||||
// TODO: rewrite it to no longer use newlib, it is way too heavy
|
||||
|
||||
static char buf[OS_INTEGER_TRACE_PRINTF_TMP_ARRAY_SIZE];
|
||||
|
||||
// Print to the local buffer
|
||||
ret = vsnprintf (buf, sizeof(buf), format, ap);
|
||||
if (ret > 0)
|
||||
{
|
||||
// Transfer the buffer to the device
|
||||
ret = trace_write (buf, (size_t)ret);
|
||||
}
|
||||
|
||||
va_end (ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
trace_puts(const char *s)
|
||||
{
|
||||
trace_write(s, strlen(s));
|
||||
return trace_write("\n", 1);
|
||||
}
|
||||
|
||||
int
|
||||
trace_putchar(int c)
|
||||
{
|
||||
trace_write((const char*)&c, 1);
|
||||
return c;
|
||||
}
|
||||
|
||||
void
|
||||
trace_dump_args(int argc, char* argv[])
|
||||
{
|
||||
trace_printf("main(argc=%d, argv=[", argc);
|
||||
for (int i = 0; i < argc; ++i)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
trace_printf(", ");
|
||||
}
|
||||
trace_printf("\"%s\"", argv[i]);
|
||||
}
|
||||
trace_printf("]);\n");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#endif // TRACE
|
|
@ -343,6 +343,60 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* adcHandle)
|
|||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
void adcGetConversion(void)
|
||||
{
|
||||
HAL_StatusTypeDef result = HAL_ADC_PollForConversion(&hadc1, 100);
|
||||
result = HAL_ADC_PollForConversion(&hadc2, 100);
|
||||
result = HAL_ADC_PollForConversion(&hadc3, 100);
|
||||
|
||||
if (result == HAL_OK)
|
||||
{
|
||||
//while(HAL_ADC_GetState(&hadc1) != HAL_ADC_STATE_REG_EOC);
|
||||
|
||||
/* Check if the continous conversion of regular channel is finished */
|
||||
// if(HAL_ADC_GetState(&hadc1) == 0x300 /*HAL_ADC_STATE_REG_EOC*/
|
||||
// && HAL_ADC_GetState(&hadc2) == 0x300 /*HAL_ADC_STATE_REG_EOC*/
|
||||
// && HAL_ADC_GetState(&hadc3) == 0x300 /*HAL_ADC_STATE_REG_EOC*/)
|
||||
|
||||
if(HAL_IS_BIT_SET(HAL_ADC_GetState(&hadc1), HAL_ADC_STATE_REG_EOC) &&
|
||||
HAL_IS_BIT_SET(HAL_ADC_GetState(&hadc2), HAL_ADC_STATE_REG_EOC) &&
|
||||
HAL_IS_BIT_SET(HAL_ADC_GetState(&hadc3), HAL_ADC_STATE_REG_EOC))
|
||||
|
||||
|
||||
{
|
||||
/*##-5- Get the converted value of regular channel ########################*/
|
||||
uhADCxConvertedValue1 = HAL_ADC_GetValue(&hadc1);
|
||||
uhADCxConvertedValue2 = HAL_ADC_GetValue(&hadc2);
|
||||
uhADCxConvertedValue3 = HAL_ADC_GetValue(&hadc3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void adcStartConversion(void)
|
||||
{
|
||||
if(HAL_ADC_Start(&hadc1) != HAL_OK)
|
||||
{
|
||||
/* Start Conversation Error */
|
||||
//Error_Handler();
|
||||
wrongThings++;
|
||||
}
|
||||
|
||||
if(HAL_ADC_Start(&hadc2) != HAL_OK)
|
||||
{
|
||||
/* Start Conversation Error */
|
||||
//Error_Handler();
|
||||
wrongThings++;
|
||||
}
|
||||
|
||||
if(HAL_ADC_Start(&hadc3) != HAL_OK)
|
||||
{
|
||||
/* Start Conversation Error */
|
||||
//Error_Handler();
|
||||
wrongThings++;
|
||||
}
|
||||
}
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
|
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
#include "si5338.h"
|
||||
//#include "stm32f7xx_hal_rcc_ex.h"
|
||||
#include "stm32f7xx.h"
|
||||
#include "diag/Trace.h"
|
||||
//#include "stm32f7xx_hal_i2c.h"
|
||||
|
||||
|
||||
#define SI5338_ADDRESS 0x70
|
||||
I2C_HandleTypeDef handleI2C;
|
||||
|
|
|
@ -90,7 +90,7 @@ void MX_GPIO_Init(void)
|
|||
|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13|GPIO_PIN_1|TESTTEST_Pin|GPIO_PIN_3, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13|GPIO_PIN_1|GPIO_PIN_3, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8
|
||||
|
@ -114,7 +114,7 @@ void MX_GPIO_Init(void)
|
|||
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PC13 PC1 PCPin PC3 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_1|TESTTEST_Pin|GPIO_PIN_3;
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_1|GPIO_PIN_3;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,12 +1,12 @@
|
|||
#include "si5338.h"
|
||||
|
||||
#include "stm32f7xx_hal.h"
|
||||
|
||||
#define NUM_REGS_MAX 350
|
||||
#define SI5338_ADDRESS 0x70
|
||||
#define LOCK_MASK 0x15
|
||||
#define LOS_MASK 0x04
|
||||
|
||||
|
||||
I2C_HandleTypeDef handleI2C;
|
||||
|
||||
//typedef struct Reg_Data{
|
||||
// unsigned unsigned char Reg_Addr;
|
||||
|
@ -375,7 +375,7 @@ void write_Si5338(unsigned char address, unsigned char value)
|
|||
unsigned char txBuf[2];
|
||||
txBuf[0] = address;
|
||||
txBuf[1] = value;
|
||||
|
||||
|
||||
HAL_I2C_Master_Transmit(&handleI2C, 0xE0, txBuf, 2, 100);
|
||||
//HAL_I2C_Mem_Write(&handleI2C, 0xE0, address, 1, value, 1, 100);
|
||||
|
||||
|
|
|
@ -0,0 +1,252 @@
|
|||
//
|
||||
// This file is part of the µOS++ III distribution.
|
||||
// Copyright (c) 2014 Liviu Ionescu.
|
||||
//
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(TRACE)
|
||||
|
||||
//#include "cmsis_device.h"
|
||||
#include "diag/Trace.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// One of these definitions must be passed via the compiler command line
|
||||
// Note: small Cortex-M0/M0+ might implement a simplified debug interface.
|
||||
|
||||
//#define OS_USE_TRACE_ITM
|
||||
//#define OS_USE_TRACE_SEMIHOSTING_DEBUG
|
||||
//#define OS_USE_TRACE_SEMIHOSTING_STDOUT
|
||||
|
||||
#if !(defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__))
|
||||
#if defined(OS_USE_TRACE_ITM)
|
||||
#undef OS_USE_TRACE_ITM
|
||||
#warning "ITM unavailable"
|
||||
#endif // defined(OS_USE_TRACE_ITM)
|
||||
#endif // !(defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__))
|
||||
|
||||
#if defined(OS_DEBUG_SEMIHOSTING_FAULTS)
|
||||
#if defined(OS_USE_TRACE_SEMIHOSTING_STDOUT) || defined(OS_USE_TRACE_SEMIHOSTING_DEBUG)
|
||||
#error "Cannot debug semihosting using semihosting trace; use OS_USE_TRACE_ITM"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Forward definitions.
|
||||
|
||||
#if defined(OS_USE_TRACE_ITM)
|
||||
static ssize_t
|
||||
_trace_write_itm (const char* buf, size_t nbyte);
|
||||
#endif
|
||||
|
||||
#if defined(OS_USE_TRACE_SEMIHOSTING_STDOUT)
|
||||
static ssize_t
|
||||
_trace_write_semihosting_stdout(const char* buf, size_t nbyte);
|
||||
#endif
|
||||
|
||||
#if defined(OS_USE_TRACE_SEMIHOSTING_DEBUG)
|
||||
static ssize_t
|
||||
_trace_write_semihosting_debug(const char* buf, size_t nbyte);
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
trace_initialize(void)
|
||||
{
|
||||
// For regular ITM / semihosting, no inits required.
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// This function is called from _write() for fd==1 or fd==2 and from some
|
||||
// of the trace_* functions.
|
||||
|
||||
ssize_t
|
||||
trace_write (const char* buf __attribute__((unused)),
|
||||
size_t nbyte __attribute__((unused)))
|
||||
{
|
||||
#if defined(OS_USE_TRACE_ITM)
|
||||
return _trace_write_itm (buf, nbyte);
|
||||
#elif defined(OS_USE_TRACE_SEMIHOSTING_STDOUT)
|
||||
return _trace_write_semihosting_stdout(buf, nbyte);
|
||||
#elif defined(OS_USE_TRACE_SEMIHOSTING_DEBUG)
|
||||
return _trace_write_semihosting_debug(buf, nbyte);
|
||||
#endif
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(OS_USE_TRACE_ITM)
|
||||
|
||||
#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
|
||||
|
||||
// ITM is the ARM standard mechanism, running over SWD/SWO on Cortex-M3/M4
|
||||
// devices, and is the recommended setting, if available.
|
||||
//
|
||||
// The JLink probe and the GDB server fully support SWD/SWO
|
||||
// and the JLink Debugging plug-in enables it by default.
|
||||
// The current OpenOCD does not include support to parse the SWO stream,
|
||||
// so this configuration will not work on OpenOCD (will not crash, but
|
||||
// nothing will be displayed in the output console).
|
||||
|
||||
#if !defined(OS_INTEGER_TRACE_ITM_STIMULUS_PORT)
|
||||
#define OS_INTEGER_TRACE_ITM_STIMULUS_PORT (0)
|
||||
#endif
|
||||
|
||||
static ssize_t
|
||||
_trace_write_itm (const char* buf, size_t nbyte)
|
||||
{
|
||||
for (size_t i = 0; i < nbyte; i++)
|
||||
{
|
||||
// Check if ITM or the stimulus port are not enabled
|
||||
if (((ITM->TCR & ITM_TCR_ITMENA_Msk) == 0)
|
||||
|| ((ITM->TER & (1UL << OS_INTEGER_TRACE_ITM_STIMULUS_PORT)) == 0))
|
||||
{
|
||||
return (ssize_t)i; // return the number of sent characters (may be 0)
|
||||
}
|
||||
|
||||
// Wait until STIMx is ready...
|
||||
while (ITM->PORT[OS_INTEGER_TRACE_ITM_STIMULUS_PORT].u32 == 0)
|
||||
;
|
||||
// then send data, one byte at a time
|
||||
ITM->PORT[OS_INTEGER_TRACE_ITM_STIMULUS_PORT].u8 = (uint8_t) (*buf++);
|
||||
}
|
||||
|
||||
return (ssize_t)nbyte; // all characters successfully sent
|
||||
}
|
||||
|
||||
#endif // defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
|
||||
|
||||
#endif // OS_USE_TRACE_ITM
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(OS_USE_TRACE_SEMIHOSTING_DEBUG) || defined(OS_USE_TRACE_SEMIHOSTING_STDOUT)
|
||||
|
||||
#include "arm/semihosting.h"
|
||||
|
||||
// Semihosting is the other output channel that can be used for the trace
|
||||
// messages. It comes in two flavours: STDOUT and DEBUG. The STDOUT channel
|
||||
// is the equivalent of the stdout in POSIX and in most cases it is forwarded
|
||||
// to the GDB server stdout stream. The debug channel is a separate
|
||||
// channel. STDOUT is buffered, so nothing is displayed until a \n;
|
||||
// DEBUG is not buffered, but can be slow.
|
||||
//
|
||||
// Choosing between semihosting stdout and debug depends on the capabilities
|
||||
// of your GDB server, and also on specific needs. It is recommended to test
|
||||
// DEBUG first, and if too slow, try STDOUT.
|
||||
//
|
||||
// The JLink GDB server fully support semihosting, and both configurations
|
||||
// are available; to activate it, use "monitor semihosting enable" or check
|
||||
// the corresponding button in the JLink Debugging plug-in.
|
||||
// In OpenOCD, support for semihosting can be enabled using
|
||||
// "monitor arm semihosting enable".
|
||||
//
|
||||
// Note: Applications built with semihosting output active normally cannot
|
||||
// be executed without the debugger connected and active, since they use
|
||||
// BKPT to communicate with the host. However, with a carefully written
|
||||
// HardFault_Handler, the semihosting BKPT calls can be processed, making
|
||||
// possible to run semihosting applications as standalone, without being
|
||||
// terminated with hardware faults.
|
||||
|
||||
#endif // OS_USE_TRACE_SEMIHOSTING_DEBUG_*
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(OS_USE_TRACE_SEMIHOSTING_STDOUT)
|
||||
|
||||
static ssize_t
|
||||
_trace_write_semihosting_stdout (const char* buf, size_t nbyte)
|
||||
{
|
||||
static int handle;
|
||||
void* block[3];
|
||||
int ret;
|
||||
|
||||
if (handle == 0)
|
||||
{
|
||||
// On the first call get the file handle from the host
|
||||
block[0] = ":tt"; // special filename to be used for stdin/out/err
|
||||
block[1] = (void*) 4; // mode "w"
|
||||
// length of ":tt", except null terminator
|
||||
block[2] = (void*) (sizeof(":tt") - 1);
|
||||
|
||||
ret = call_host (SEMIHOSTING_SYS_OPEN, (void*) block);
|
||||
if (ret == -1)
|
||||
return -1;
|
||||
|
||||
handle = ret;
|
||||
}
|
||||
|
||||
block[0] = (void*) handle;
|
||||
block[1] = (void*) buf;
|
||||
block[2] = (void*) nbyte;
|
||||
// send character array to host file/device
|
||||
ret = call_host (SEMIHOSTING_SYS_WRITE, (void*) block);
|
||||
// this call returns the number of bytes NOT written (0 if all ok)
|
||||
|
||||
// -1 is not a legal value, but SEGGER seems to return it
|
||||
if (ret == -1)
|
||||
return -1;
|
||||
|
||||
// The compliant way of returning errors
|
||||
if (ret == (int) nbyte)
|
||||
return -1;
|
||||
|
||||
// Return the number of bytes written
|
||||
return (ssize_t) (nbyte) - (ssize_t) ret;
|
||||
}
|
||||
|
||||
#endif // OS_USE_TRACE_SEMIHOSTING_STDOUT
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(OS_USE_TRACE_SEMIHOSTING_DEBUG)
|
||||
|
||||
#define OS_INTEGER_TRACE_TMP_ARRAY_SIZE (16)
|
||||
|
||||
static ssize_t
|
||||
_trace_write_semihosting_debug (const char* buf, size_t nbyte)
|
||||
{
|
||||
// Since the single character debug channel is quite slow, try to
|
||||
// optimise and send a null terminated string, if possible.
|
||||
if (buf[nbyte] == '\0')
|
||||
{
|
||||
// send string
|
||||
call_host (SEMIHOSTING_SYS_WRITE0, (void*) buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If not, use a local buffer to speed things up
|
||||
char tmp[OS_INTEGER_TRACE_TMP_ARRAY_SIZE];
|
||||
size_t togo = nbyte;
|
||||
while (togo > 0)
|
||||
{
|
||||
unsigned int n = ((togo < sizeof(tmp)) ? togo : sizeof(tmp));
|
||||
unsigned int i = 0;
|
||||
for (; i < n; ++i, ++buf)
|
||||
{
|
||||
tmp[i] = *buf;
|
||||
}
|
||||
tmp[i] = '\0';
|
||||
|
||||
call_host (SEMIHOSTING_SYS_WRITE0, (void*) tmp);
|
||||
|
||||
togo -= n;
|
||||
}
|
||||
}
|
||||
|
||||
// All bytes written
|
||||
return (ssize_t) nbyte;
|
||||
}
|
||||
|
||||
#endif // OS_USE_TRACE_SEMIHOSTING_DEBUG
|
||||
|
||||
#endif // TRACE
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue