RS41ng/src/gpio.h

105 wiersze
2.5 KiB
C
Czysty Zwykły widok Historia

Graw DFM-17 radiosonde support (#61) * Initial plumbing for DFM17 (#54) * Implementing Si4063 radio chip support for DFM17 sonde. Work in progress. * Add an error to indicate that the code does not work yet * Removed copyrighted docs from documentation and provided links instead (#55) * Fix SPI bus initialization for DFM17. Trying to make Si4063 SPI communication work (in progress). Fix LED bit polarity. * Set DFM17 clocks correctly to 24 MHz * Still trying to fix Si4063 SPI communication, no luck * Add clearing of SPI overrun status flag to make Si4063 comm work properly in DFM17. Not sure about the reason this is required. * Fix bug when setting Si4063 frequency. Remove unnecessary GPS debug and delays. Add Si4063 debug printout. Find a suitable frequency offset multiplier to achieve 270 Hz tone spacing for Horus 4FSK. * Add some known good Si4063 configuration values. Implement direct GPIO-based modulation for Si4063 that allows support for CW now. * DFM-17 APRS work (#60) * Modify for APRS on DFM17 * Clean up Si4063 APRS work and make APRS deviation configurable * Add documentation for DFM-17 * Add a note about the DFM-17 connector * More work on docs and config for DFM-17 * Docs * Mor work on config * Fix RS41 URL * Added info about high-altitude balloon flights * Fix typo * More code cleanup * Update authors * Improve DFM-17 docs * Added a timepulse routine for DFM17 and also a millis() routine. Working toward clock calibration. * More refinements to the HCI calibration * Cleaned up clock calibration code and integrated into the main radio loop. Also added APRS telemetry for calibration. * Added logic to (hopefully) avoid over-calibration if there is an errant timepulse. * Clean up DFM-17 clock calibration implementation and make RS41 compile properly * Adjust README * Add notes about DFM-17 clock calibration * Fix typo * Add DFM-17 note about clock calibration to the top of the README * Text style * Working on README * Working on README * Move datasheet links to main README * Markdown styling * Improve config file structure * Remove unnecessary comments --------- Co-authored-by: Mike Hojnowski <kd2eat@gmail.com>
2023-10-15 09:38:05 +00:00
#ifndef __GPIO_H
#define __GPIO_H
#include <system_stm32f10x.h>
#include <stm32f10x_gpio.h>
#include "config.h"
// GPIO definitions for devices we use
#if defined (RS41)
#define BANK_SHUTDOWN GPIOA
#define PIN_SHUTDOWN GPIO_Pin_12
#define BANK_VOLTAGE GPIOA
#define PIN_VOLTAGE GPIO_Pin_5
#define ADC_VOLTAGE ADC1
#define CHANNEL_VOLTAGE ADC_Channel_5
#define BANK_BUTTON GPIOA
#define PIN_BUTTON GPIO_Pin_6
#define ADC_BUTTON ADC1
#define CHANNEL_BUTTON ADC_Channel_6
#define BANK_RED_LED GPIOB
#define PIN_RED_LED GPIO_Pin_8
#define BANK_GREEN_LED GPIOB
#define PIN_GREEN_LED GPIO_Pin_7
#define BANK_MOSI GPIOB
#define PIN_MOSI GPIO_Pin_15
#define BANK_SCK GPIOB
#define PIN_SCK GPIO_Pin_13
#define BANK_MISO GPIOB
#define PIN_MISO GPIO_Pin_14
#define APBPERIPHERAL_SPI RCC_APB1Periph_SPI2
#define PERIPHERAL_SPI SPI2
#define RCC_SPIPeriphClockCmd RCC_APB1PeriphClockCmd
#define PIN_USART_TX GPIO_Pin_9
#define BANK_USART_TX GPIOA
#define PIN_USART_RX GPIO_Pin_10
#define BANK_USART_RX GPIOA
#define USART_IRQ USART1_IRQn
#define USART_IT USART1
#define APBPERIPHERAL_USART RCC_APB2Periph_USART1
#define USART_IRQ_HANDLER USART1_IRQHandler
#elif defined (DFM17)
#define BANK_SHUTDOWN GPIOC
#define PIN_SHUTDOWN GPIO_Pin_0
#define BANK_VOLTAGE GPIOA // Needs confirmation
#define PIN_VOLTAGE GPIO_Pin_0 // Needs confirmation
#define ADC_VOLTAGE ADC1 // Needs confirmation
#define CHANNEL_VOLTAGE ADC_Channel_0 // Needs confirmation
#define BANK_BUTTON GPIOC
#define PIN_BUTTON GPIO_Pin_8
// No ADC available on the GPIOC, so we have to use digital reads/writes for the button
#define BANK_RED_LED GPIOB
#define PIN_RED_LED GPIO_Pin_12
#define BANK_GREEN_LED GPIOC
#define PIN_GREEN_LED GPIO_Pin_6
#define BANK_YELLOW_LED GPIOC
#define PIN_YELLOW_LED GPIO_Pin_7
#define BANK_MOSI GPIOA
#define PIN_MOSI GPIO_Pin_7
#define BANK_SCK GPIOA
#define PIN_SCK GPIO_Pin_5
#define BANK_MISO GPIOA
#define PIN_MISO GPIO_Pin_6
#define APBPERIPHERAL_SPI RCC_APB2Periph_SPI1
#define PERIPHERAL_SPI SPI1
#define RCC_SPIPeriphClockCmd RCC_APB2PeriphClockCmd
#define PIN_USART_TX GPIO_Pin_2
#define BANK_USART_TX GPIOA
#define PIN_USART_RX GPIO_Pin_3
#define BANK_USART_RX GPIOA
#define USART_IRQ USART2_IRQn
#define USART_IT USART2
#define APBPERIPHERAL_USART RCC_APB1Periph_USART2
#define USART_IRQ_HANDLER USART2_IRQHandler
#else
Compiler error. You must define RS41 or DFM17.
#endif // RS41 or DFM17
// Hardware Sanity Check
#if defined (RS41) && defined (DFM17)
Compiler error. You must define RS41 or DFM17 but not both.
#endif
#endif // __GPIO_H