prototype version with splited RX and TX pin for dallas one wire

pull/2/head
Mateusz Lubecki 2019-08-21 18:38:45 +02:00
rodzic 534be2cd96
commit a48ad961cf
4 zmienionych plików z 156 dodań i 4 usunięć

Wyświetl plik

@ -3,8 +3,8 @@
#include "aprs/ax25.h"
#define SW_VER "DC03"
#define SW_DATE "07072019"
#define SW_VER "DE00"
#define SW_DATE "21082019"
#define SYSTICK_TICKS_PER_SECONDS 100
#define SYSTICK_TICKS_PERIOD 10

Wyświetl plik

@ -0,0 +1,118 @@
/*
* config.h
*
* Created on: 03.07.2017
* Author: mateusz
*/
#ifndef STATION_CONFIG_H_
#define STATION_CONFIG_H_
// Only for debugging
//#define _DBG_TRACE
// Uncomment to enable all meteo functionality. TX20 anemometer, dallas termometer, MS5611 pressure sens
//#define _METEO
#define _DIGI // Comment this do disable WIDE1-1 digipeating
#define _DIGI_ONLY_789
//#define _DALLAS_AS_TELEM
//#define _VICTRON
//#define _MUTE_RF // TODO: Not yet implemented - This will make station RXonly and disable all data transmission
//#define _MUTE_OWN // TODO: Not yet implemented - This will disable all self-generated packets (wx, telemetry, beacon)
// and switch device to "pure" kiss TNC operation. Packets from PC will be transmitted normally.
// Coordines should be in APRS decimal format DDDMM.SS for Longitude and DDMM.SS for latitude
#define _CALL "SR9NCI"
#define _SSID 0
#define _LAT 4944.22
#define _LATNS 'N'
#define _LON 01838.20
#define _LONWE 'E'
#define _COMMENT "DigiW1 - SSID789 only - TXP 500mW @ Slask Ciesynski by SP8EBC"
// 49°44.22' N 18°38.20'
// You can use only one of these below defines to choose symbol. Meteo data are are always transmitted with blue WX symbol
//#define _SYMBOL_DIGI // uncomment if you want digi symbol(green star with D inside)
#define _SYMBOL_WIDE1_DIGI // uncomment if you want 'little' digi symbol (green star with digit 1 overlaid)
//#define _SYMBOL_HOUSE // uncomment if you want house symbol
//#define _SYMBOL_RXIGATE // uncomment if you want rxigate symbol (black diamond with R)
//#define _SYMBOL_IGATE // uncomment if you want igate symol (black diamond with I)
// Or you can keep commented all symbol defines and choose custom one based on data from APRS symbols table
//#define _SYMBOL_F '/'
//#define _SYMBOL_S '#'
// Uncomment one of these two defines to choose what path You want. If you uncommend both of them or
// if you keep both commended path will be completely disabled. CALL-S>AKLPRZ:data
//#define _WIDE1_PATH // CALL-S>AKLPRZ,WIDE1-1:data
#define _WIDE21_PATH // CALL-S>AKLPRZ,WIDE2-1:data
// Comment this to disable beacon auto sending during startup (this can be risky if RF feedback occur)
#define _BCN_ON_STARTUP
#define _WX_INTERVAL 4 // WX packet interval in minutes
#define _BCN_INTERVAL 15 // Own beacon interval in minutes
//#define _PTT_PUSHPULL // Uncomment this if you want PTT line to work as Push-pull instead of Open Drain
#define _SERIAL_BAUDRATE 9600
// Transmitting delay
#define _DELAY_BASE 19 // * 50ms. For example setting 10 gives 500msec delay. Maximum value is 20
//#define _RANDOM_DELAY // adds random delay TO fixed time set by _DELAY_BASE. This additional time can be
// from 100ms up to 1 sec in 100ms steps. Values are drawn from samples going from ADC
// so it is better to use Unsquelched output in radio to provide much more randomness
//After waiting time declared above ParaTNC will check DCD (Data Carrier Detect) flag, which works as some
//kind of semaphore. If radio channel is not occupied by any other transmission TX will be keyed up immediately,
//otherwise software will wait for clear conditions.
// Few IMPORTANT hints about setting transmit delay properly.
//
// Transmit delay is key parameter to maintain RF network free from packet losses and collisions. If your station will be
// installed on tall object, without any other digi's close to it, you can set _DELAY_BASE to very low value and disable
// _RANDOM_DELAY. If you wanna rather auxiliary station, witch should only fill gap in RF coverage in small area, then
// _DELAY_BASE parameter should be not less than 12 (600msec), the smallest range the higher _DELAY_BASE should be.
// Additionally for gapfillers (auxiliary stations) _RANDOM_DELAY schould be enabled.
//
// This delay will ensure that while other station will be transmitting repeated packets from mobile, Yours will keep
// always quiet and won't jam RF network. This greatly improve DCD based access to channel. Various controllers uses
// various lenght of preamble, some of them produce signal which might be impossible to decode by ParaTNC, so DCD
// is only one part of effective multiaccess to medium.
// Do not touch this
#if defined (_SYMBOL_DIGI) && !defined (_SYMBOL_WIDE1_DIGI) && !defined (_SYMBOL_HOUSE) && !defined (_SYMOL_RXIGATE) &&\
!defined (_SYMBOL_IGATE)
#define _SYMBOL_F '/'
#define _SYMBOL_S '#'
#elif !defined (_SYMBOL_DIGI) && defined (_SYMBOL_WIDE1_DIGI) && !defined (_SYMBOL_HOUSE) && !defined (_SYMOL_RXIGATE) &&\
!defined (_SYMBOL_IGATE)
#define _SYMBOL_F '1'
#define _SYMBOL_S '#'
#elif !defined (_SYMBOL_DIGI) && !defined (_SYMBOL_WIDE1_DIGI) && defined (_SYMBOL_HOUSE) && !defined (_SYMOL_RXIGATE) &&\
!defined (_SYMBOL_IGATE)
#define _SYMBOL_F '/'
#define _SYMBOL_S '-'
#elif !defined (_SYMBOL_DIGI) && !defined (_SYMBOL_WIDE1_DIGI) && !defined (_SYMBOL_HOUSE) && defined (_SYMOL_RXIGATE) &&\
!defined (_SYMBOL_IGATE)
#define _SYMBOL_F 'I'
#define _SYMBOL_S '&'
#elif !defined (_SYMBOL_DIGI) && !defined (_SYMBOL_WIDE1_DIGI) && !defined (_SYMBOL_HOUSE) && !defined (_SYMOL_RXIGATE) &&\
defined (_SYMBOL_IGATE)
#define _SYMBOL_F 'R'
#define _SYMBOL_S '&'
#elif !defined (_SYMBOL_F) && !defined (_SYMBOL_S)
#error "Missing symbol configuration in station_config.h"
#elif defined (_SYMBOL_F) && defined (_SYMBOL_S)
#else
#error "Wrong symbol configuration in station_config.h"
#endif
#if defined (_METEO) && !defined (_DIGI)
#define _DIGI
#endif
#endif /* STATION_CONFIG_H_ */

Wyświetl plik

@ -14,6 +14,8 @@ extern "C" {
#endif
#include <stm32f10x_gpio.h>
#include "station_config.h"
extern volatile int delay_5us;
@ -22,6 +24,9 @@ extern volatile char timm;
typedef struct DallasStruct {
GPIO_TypeDef* GPIOx; /*!< GPIOx port to be used for I/O functions */
uint16_t GPIO_Pin; /*!< GPIO Pin to be used for I/O functions */
#ifdef _DALLAS_SPLIT_PIN
uint16_t GPIO_Pin_input;
#endif
uint32_t GPIO_Cnf; /*!< GPIO Pin to be used for I/O functions */
uint32_t GPIO_Mode; /*!< GPIO Pin to be used for I/O functions */
uint32_t input_term;

Wyświetl plik

@ -28,6 +28,7 @@ void dallas_init(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, uint16_t GPIO_PinSource
// GPIO_input.GPIO_Speed = GPIO_Speed_50MHz;
// GPIO_Init(GPIOx, &GPIO_input);
#ifndef _DALLAS_SPLIT_PIN
dallas.GPIOx = GPIOx;
dallas.GPIO_Pin = GPIO_Pin;
@ -39,6 +40,25 @@ void dallas_init(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, uint16_t GPIO_PinSource
dallas.input_term = 1 << dallas.shift;
dallas.output_term = (1 << dallas.shift - 2) | (1 << dallas.shift);
#else
GPIO_InitTypeDef GPIO_input;
GPIO_InitTypeDef GPIO_output;
GPIO_output.GPIO_Mode = GPIO_Mode_Out_OD;
GPIO_output.GPIO_Pin = GPIO_Pin;
GPIO_output.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_SetBits(GPIOx, GPIO_Pin);
GPIO_input.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_input.GPIO_Pin = GPIO_Pin << 1;
GPIO_input.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOx, &GPIO_input);
dallas.GPIOx = GPIOx;
dallas.GPIO_Pin = GPIO_Pin;
dallas.GPIO_Pin_input = GPIO_Pin << 1;
#endif
}
void dallas_config_timer(void) {
@ -80,21 +100,25 @@ void dallas_deconfig_timer(void) {
char dallas_reset(void) {
// PULLING LINE LOW
#ifndef _DALLAS_SPLIT_PIN
dallas.GPIOx->CRL &= dallas.clear_term;
dallas.GPIOx->CRL |= dallas.output_term;
#endif
dallas.GPIOx->BSRR |= (dallas.GPIO_Pin << 16); // line low
delay_5us = 100; // delay 500us
while (delay_5us != 0);
// WAITING FOR SLAVE PRESENT PULSE
dallas.GPIOx->BSRR |= (dallas.GPIO_Pin); // line high
#ifndef _DALLAS_SPLIT_PIN
dallas.GPIOx->CRL &= dallas.clear_term;
dallas.GPIOx->CRL |= dallas.input_term;
#endif
delay_5us = 20; // delay 100us
while (delay_5us != 0);
// READING PIN STATE
if ((dallas.GPIOx->IDR & dallas.GPIO_Pin) == GPIO_Pin_6) {
if ((dallas.GPIOx->IDR & dallas.GPIO_Pin) == dallas.GPIO_Pin) {
delay_5us = 100; // delay 500us
while (delay_5us != 0);
return -1;
@ -109,8 +133,10 @@ void __attribute__((optimize("O0"))) dallas_send_byte(char data) {
char i;
for (i = 0; i < 8; i++) {
// PULLING LINE LOW
#ifndef _DALLAS_SPLIT_PIN
dallas.GPIOx->CRL &= dallas.clear_term;
dallas.GPIOx->CRL |= dallas.output_term;
#endif
dallas.GPIOx->BSRR |= (dallas.GPIO_Pin << 16); // line low
delay_5us = ((data >> i) & 0x01) ? 2 : 13; // delay 10us if sending logic "1", or 75us if "0"
while (delay_5us != 0);
@ -129,17 +155,20 @@ char __attribute__((optimize("O0"))) dallas_receive_byte(void) {
for (i = 0; i < 8; i++) {
// PULLING LINE LOW
#ifndef _DALLAS_SPLIT_PIN
dallas.GPIOx->CRL &= dallas.clear_term;
dallas.GPIOx->CRL |= dallas.output_term;
#endif
dallas.GPIOx->BSRR |= (dallas.GPIO_Pin << 16); // line low
delay_5us = 2; // delay 10us
while (delay_5us != 0);
// PULLING LINE BACK HIGH
dallas.GPIOx->BSRR |= (dallas.GPIO_Pin); // line high
// GPIO_Init(dallas.GPIOx, &GPIO_input); // przeroic!!
#ifndef _DALLAS_SPLIT_PIN
dallas.GPIOx->CRL &= dallas.clear_term;
dallas.GPIOx->CRL |= dallas.input_term;
#endif
delay_5us = 1; // delay 10us
while (delay_5us != 0);