Konfiguracja szybkości RTTY

aprs_test
Łukasz Nidecki 2016-12-24 22:23:49 +01:00
rodzic 87a847708f
commit 67b660d8e6
6 zmienionych plików z 54 dodań i 26 usunięć

Wyświetl plik

@ -8,6 +8,8 @@
#define CALLSIGN "NO1LIC-1" // put your callsign here
//*************frequency********************
#define freq 434.150f //Mhz middle frequency
//************rtty speed****************** si4032
#define RTTY_SPEED 300
//************band select****************** si4032
#define fb 1
#define fbsel 1

47
init.c
Wyświetl plik

@ -14,6 +14,9 @@ USART_InitTypeDef USART_InitStructure;
GPIO_InitTypeDef GPIO_Conf;
ADC_InitTypeDef ADC_InitStructure;
DMA_InitTypeDef DMA_InitStructure;
#define ADC1_DR_Address ((uint32_t)0x4001244C)
void NVIC_Conf()
@ -55,25 +58,8 @@ void init_port()
GPIO_Conf.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Conf.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_Init(GPIOB, &GPIO_Conf);
TIM_TimeBaseInitTypeDef TIM2_TimeBaseInitStruct;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2,ENABLE);
RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM2,DISABLE);
TIM2_TimeBaseInitStruct.TIM_Prescaler = 1000;
TIM2_TimeBaseInitStruct.TIM_CounterMode = TIM_CounterMode_Up;
TIM2_TimeBaseInitStruct.TIM_Period = 6;
TIM2_TimeBaseInitStruct.TIM_ClockDivision = TIM_CKD_DIV1;
TIM2_TimeBaseInitStruct.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit(TIM2,&TIM2_TimeBaseInitStruct);
TIM_ClearITPendingBit(TIM2,TIM_IT_Update);
TIM_ITConfig(TIM2,TIM_IT_Update,ENABLE);
NVIC_InitTypeDef NVIC_InitStructure; //create NVIC structure
NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
TIM_Cmd(TIM2,ENABLE);
GPIO_Conf.GPIO_Pin = GPIO_Pin_13 |GPIO_Pin_15;
GPIO_Conf.GPIO_Pin = GPIO_Pin_13 |GPIO_Pin_15;
GPIO_Conf.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Conf.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_Init(GPIOB, &GPIO_Conf);
@ -174,3 +160,26 @@ void init_port()
while(ADC_GetCalibrationStatus(ADC1));
ADC_SoftwareStartConvCmd(ADC1, ENABLE); // start conversion (will be endless as we are in continuous mode)
}
void init_timer(const int rtty_speed) {
TIM_TimeBaseInitTypeDef TIM2_TimeBaseInitStruct;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2,ENABLE);
RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM2,DISABLE);
TIM2_TimeBaseInitStruct.TIM_Prescaler = 600;
TIM2_TimeBaseInitStruct.TIM_CounterMode = TIM_CounterMode_Up;
TIM2_TimeBaseInitStruct.TIM_Period = (uint16_t) ((10000 / rtty_speed) - 1);
TIM2_TimeBaseInitStruct.TIM_ClockDivision = TIM_CKD_DIV1;
TIM2_TimeBaseInitStruct.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit(TIM2,&TIM2_TimeBaseInitStruct);
TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
TIM_ITConfig(TIM2,TIM_IT_Update, ENABLE);
NVIC_InitTypeDef NVIC_InitStructure; //create NVIC structure
NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
TIM_Cmd(TIM2,ENABLE);
}

1
init.h
Wyświetl plik

@ -2,3 +2,4 @@ __IO uint16_t ADCVal[2];
void NVIC_Conf();
void RCC_Conf();
void init_port();
void init_timer(const int rtty_speed);

13
main.c
Wyświetl plik

@ -116,8 +116,6 @@ unsigned char bOFF = 0;
unsigned char bCheckKay = 0;
unsigned char GPSConf = 0;
void USART1_IRQHandler(void) {
if ((USART1->SR & USART_FLAG_RXNE) != (u16) RESET) {
@ -166,7 +164,7 @@ void TIM2_IRQHandler(void) {
if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET) {
TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
}
if (tx_on && ++cun_rtty == 17) {
if (tx_on /*&& ++cun_rtty == 17*/) {
cun_rtty = 0;
send_rtty_status = send_rtty(rtty_buf);
if (send_rtty_status == rttyEnd) {
@ -175,7 +173,7 @@ void TIM2_IRQHandler(void) {
tx_on = 0;
tx_on_delay = tx_delay;//2500;
tx_enable = 0;
temp = radio_rw_register(0x07, 0x40, 1);
radio_disable_tx();
}
} else if (send_rtty_status == rttyOne) {
temp = radio_rw_register(0x73, 0x02, 1);
@ -214,6 +212,7 @@ int main(void) {
RCC_Conf();
NVIC_Conf();
init_port();
init_timer(RTTY_SPEED);
wsk_GPS_buf = GPS_buf;
@ -226,13 +225,14 @@ int main(void) {
temp = radio_rw_register(0x03, 0xff, 0);
temp = radio_rw_register(0x04, 0xff, 0);
temp = radio_rw_register(0x07, 0x80, 1);
radio_soft_reset();
print(init_trx);
// programowanie czestotliwosci nadawania
radio_set_tx_frequency();
// Programowanie mocy nadajnika
temp = radio_rw_register(0x6D, 00 | (Smoc & 0x0007), 1);
temp = radio_rw_register(0x71, 0x00, 1);
temp = radio_rw_register(0x87, 0x08, 0);
temp = radio_rw_register(0x02, 0xff, 0);
@ -288,8 +288,9 @@ int main(void) {
CRC_rtty = gps_CRC16_checksum(buf_rtty + 7);
sprintf(buf_rtty, "%s*%04X\n", buf_rtty, CRC_rtty & 0xffff);
rtty_buf = buf_rtty;
radio_enable_tx();
tx_on = 1;
temp = radio_rw_register(0x07, 0x48, 1);
send_cun++;
}

14
radio.c
Wyświetl plik

@ -24,4 +24,16 @@ void radio_set_tx_frequency() {
radio_rw_register(0x75, 0x61, 1); // FIXME: tutaj powinno zdaje się być ustawiane fbsel?!
radio_rw_register(0x76, (uint8_t) (((uint16_t)fc >> 8) & 0xff), 1);
radio_rw_register(0x77, (uint8_t) ((uint16_t)fc & 0xff), 1);
}
}
void radio_disable_tx() {
radio_rw_register(0x07, 0x40, 1);
}
void radio_soft_reset() {
radio_rw_register(0x07, 0x80, 1);
}
void radio_enable_tx() {
radio_rw_register(0x07, 0x48, 1);
}

Wyświetl plik

@ -22,5 +22,8 @@ static const uint8_t WR = 0x80;
uint8_t _spi_sendrecv(const uint16_t data_word);
uint8_t radio_rw_register(const uint8_t register_addr, uint8_t value, uint8_t write);
void radio_set_tx_frequency();
void radio_disable_tx();
void radio_soft_reset();
void radio_enable_tx();
#endif //STM32_RTTY_RADIO_H