亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? main.c

?? rds解碼過程
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*

Copyright (C) 2006 Marc Ketel

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

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 General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

*/

#define INFO "20060629-1 RDS Decoder by Marc Ketel alias DiNo, marc@atoomnet.net."
/*

Works with RDS clock signal and RDS data signal. During design a TDA7300B rds demodulator was used.

This source compiles correctly with WinAVR 20060421.

Use a Atmega168 to flash program into. low fuse: 0xF0, high fuse: 0xDD

Versions:
  20060629-1  Initial version

*/

/*

general word on ISR: it does not seem that ISR has global interrupts disabled.

*/

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <avr/wdt.h>
#include <stdio.h>
#include <math.h>

#define RDS_PORT PIND
#define RDS_PIN  PD4

FILE* Uart;

//used for stdout
int uartSend(char data, FILE* stream) {
  //wait for completion of previous send
  loop_until_bit_is_set(UCSR0A, UDRE0);

  //send the data
  UDR0 = data;
  return 0;
}

//used for stdin
int uartRecv(FILE* stream) {
  loop_until_bit_is_set(UCSR0A, RXC0);
  return UDR0;
}

volatile unsigned char event = 0;
#define eventTimerOverflow      _BV(0)
#define eventUsart0RxDInterrupt _BV(1)
#define eventGroupComplete      _BV(2)
#define eventBitstreamSnapshot  _BV(3)
#define eventSyncLost           _BV(4)

volatile unsigned char timerOverflowCount = 0;
volatile unsigned char usart0RxDByte = 0;
volatile unsigned char bitCounter = 0;
volatile unsigned char bitCounterSnapshot = 0;

volatile unsigned char synchronized = 0;
volatile unsigned char syncQuality = 0; //0-31, 0=no useable signal, 15=medium quality, 31=perfect!
volatile unsigned char syncCounter = 0;

volatile unsigned char block = 0;
volatile unsigned long bitstream = 0;
volatile unsigned long bitstreamData = 0;
volatile unsigned int block1 = 0;
volatile unsigned int block2 = 0;
volatile unsigned int block3 = 0;
volatile unsigned int block4 = 0;

//ISR is executed when there is a new rds bit to read
ISR(INT0_vect) {
  cli();
  unsigned int syndrome = 0;
  
  //Copy global vars to local vars for performance
  unsigned long bitstreamLocal = bitstream;
  unsigned char blockLocal = block;
  
  //shift rds bit in on right side
  bitstreamLocal *= 2; 
  if (RDS_PORT & _BV(RDS_PIN))
    bitstreamLocal++;
    
  bitCounter++;
  
  //collect data for raw bitstream snapshots
  bitCounterSnapshot++;
  if (bitCounterSnapshot == 26) {
    bitstreamData = (bitstreamLocal & 0x3FFFFFF);
    bitCounterSnapshot = 0;
    
    event |= eventBitstreamSnapshot;
  }
  
  //when we have 26 bits or are not synchronized to the stream
  //check the CRC and maybe store a rds block
  if (bitCounter == 26 || !synchronized) {
  
    bitstreamLocal &= 0x3FFFFFF; //we only need 26 bits
  
    syndrome = (bitstreamLocal / 0x10000); //bits 16-31 (2^16)
  
    if (bitstreamLocal & _BV(0))
      syndrome ^= 0x031b;
    
    if (bitstreamLocal & _BV(1))
      syndrome ^= 0x038f;
    
    if (bitstreamLocal & _BV(2))
      syndrome ^= 0x02a7;
      
    if (bitstreamLocal & _BV(3))
      syndrome ^= 0x00f7;
    
    if (bitstreamLocal & _BV(4))
      syndrome ^= 0x01ee;
    
    if (bitstreamLocal & _BV(5))
      syndrome ^= 0x03dc;
    
    if (bitstreamLocal & _BV(6))
      syndrome ^= 0x0201;
    
    if (bitstreamLocal & _BV(7))
      syndrome ^= 0x01bb;
    
    if (bitstreamLocal & _BV(8))
      syndrome ^= 0x0376;
    
    if (bitstreamLocal & _BV(9))
      syndrome ^= 0x0355;
  
    if (bitstreamLocal & _BV(10))
      syndrome ^= 0x0313;
    
    if (bitstreamLocal & _BV(11))
      syndrome ^= 0x039f;
  
    if (bitstreamLocal & _BV(12))
      syndrome ^= 0x0287;
      
    if (bitstreamLocal & _BV(13))
      syndrome ^= 0x00b7;
    
    if (bitstreamLocal & _BV(14))
      syndrome ^= 0x016e;

    if (bitstreamLocal & 0b1000000000000000) // _BV(15) does not work!!!
      syndrome ^= 0x02dc;

    //Block A?
    if (blockLocal == 0 && syndrome == 0x03d8) {
      block1 = bitstreamLocal / 0x400; //bits 10-25 (2^10)
      synchronized = 1;
      blockLocal++;
    } else 
    //Block B?
    if (blockLocal == 1 && syndrome == 0x03d4) {
      block2 = bitstreamLocal / 0x400; //bits 10-25 (2^10)
      synchronized = 1;
      blockLocal++;
    } else  
    //Block C type A?
    if (blockLocal == 2 && !(block2 & _BV(11)) && syndrome == 0x025c) {
      block3 = bitstreamLocal / 0x400; //bits 10-25 (2^10)
      synchronized = 1;
      blockLocal++;
    } else
    //Block C type B?
    if (blockLocal == 2 && (block2 & _BV(11)) && syndrome == 0x03cc) {
      block3 = bitstreamLocal / 0x400; //bits 10-25 (2^10)
      synchronized = 1;
      blockLocal++;
    } else
    //Block D?
    if (blockLocal == 3 && syndrome == 0x0258) {
      block4 = bitstreamLocal / 0x400; //bits 10-25 (2^10)
      synchronized = 1;
      blockLocal = 0;
      //we have a complete group!
      event |= eventGroupComplete;
    } else {
      //sync lost..
      synchronized = 0;
      blockLocal = 0;
      event |= eventSyncLost;
    }
    
    bitCounter = 0; 
  }
  
  if (event & eventGroupComplete) {
    PORTC |= _BV(PC1);
    
    if (syncQuality < 31)
      syncQuality++;
    
  } else if (!synchronized) {
    PORTC &= ~_BV(PC1);
    
    syncCounter++;
    if (syncQuality > 0 && syncCounter == 26) {
      syncQuality--;
      syncCounter = 0;
    }
      
  }
  
  if (syncQuality >= 15)
    PORTC |= _BV(PC2);
  else
    PORTC &= ~_BV(PC2);
  
  //Store local vars into global vars to remember state
  bitstream = bitstreamLocal;
  block = blockLocal;
  sei();
}

//timer0 overflowed
ISR(TIMER0_OVF_vect) {
  cli();
  timerOverflowCount++;
  if (timerOverflowCount > 4) {
    event |= eventTimerOverflow;
    timerOverflowCount = 0;
  }
  sei();
}

ISR(USART_RX_vect) {
  cli();
  usart0RxDByte = UDR0;
  event |= eventUsart0RxDInterrupt;
  sei();
}

void displayInfo(void) {
  printf_P(PSTR("INFO: 0x01, "));
  printf_P(PSTR(INFO));
  printf_P(PSTR("\r\n"));
}

int main(void) {

  wdt_reset(); //reset inmediately in case of a previous system reset
  //lets enable watchdog with 1 second timeout
  wdt_enable(WDTO_1S);

  unsigned int  programmeIdentificationCode = 0;
  unsigned char groupType = 0;
  unsigned char groupVersion = 0;
  unsigned char trafficProgrammeIdentificationCode = 0;
  unsigned char programmeTypeCode = 0;
  unsigned char trafficAnnouncementCode = 0;
  unsigned char musicSpeechSwitchScode = 0;
  unsigned char group0CodeBits = 0;
  unsigned char group0CodeBitsSteadyCount = 0;
  unsigned char programmeServiceName[8];
  unsigned char programmeServiceNameNew[8];
  unsigned char decoderIdentificationControlCode = 0;
  unsigned char decoderIdentificationControlCodeNew = 0;
  unsigned char alternativeFrequencyCodes[27];
  unsigned char syncMessage = 0;
  unsigned char displayRaw = 0;
  unsigned char displayBitstream = 0;
  unsigned char linkageActuator = 0;
  unsigned char extendedCountryCode = 0;
  unsigned char textSegmentAddress = 0;
  unsigned char textSegmentAddressPrevious = 0;
  unsigned char textVersion = 0;
  unsigned char textVersionPrevious = 0; 
  unsigned char radioText[64];
  unsigned char radioTextPrevious[64];
  unsigned char textSegmentAddress0Seen = 0;
  unsigned int  modifiedJulianDay = 0;
  unsigned int  utcYear = 0;
  unsigned char utcMonth = 0;
  unsigned char utcDay = 0;
  signed   char localHours = 0;
  unsigned char utcHours = 0;
  signed   char localMinutes = 0;
  unsigned char utcMinutes = 0;
  unsigned char utcMinutesPrevious = 0xFF;
  unsigned char localSign = 0;
  unsigned int  localTimeOffset = 0;
  
  //general purpose vars
  unsigned int  m;
  unsigned char h;
  unsigned char i;
  unsigned char j;
  
  //1.8mhz crystal
  //baudrate 115.2K
  //UBRR0 = 0;
  //baudrate 9600
  //UBRR0 = 11;
  
  //16mhz crystal
  //38.4k
  //UBRR0 = 25;
  
  //4.332Mhz crystal
  //baudrate 38K4
  UBRR0 = 6;
  
  //enable RxD interrupt, RxD, TxD
  UCSR0B |= _BV(RXCIE0) | _BV(RXEN0) | _BV(TXEN0);
  
  //8 bit
  //UCSR0C |= _BV(UCSZ00) | _BV(UCSZ01);
  
  //UART is stdout and stdin;
  Uart = fdevopen(uartSend, uartRecv);

  //enable int0
  EIMSK = _BV(INT0);
  
  //INT0 raising edge
  EICRA |= _BV(ISC01) | _BV(ISC00);
  
  //PC0, PC1, PC2 are outputs;
  DDRC |= _BV(PC0) | _BV(PC1) | _BV(PC2);

  //timer0 prescaler clk/1024
  TCCR0B |= _BV(CS02) | _BV(CS00);
  //enable overflow interrupt
  TIMSK0 |= _BV(TOIE0);
  
  displayInfo();
  
  sei(); //enable interrupts;
  
  for (;;) {
    
    do {} while (!event);
    wdt_reset(); //reset watchdog, we are still alive!
    
    cli();
    if (event & eventUsart0RxDInterrupt) {
      event &= ~eventUsart0RxDInterrupt;
      sei();
      
      //collect the command
      
      //switch group display on (G) or off (g)
      if (usart0RxDByte == 'G')
        displayRaw = 0;
      else if (usart0RxDByte == 'g')
        displayRaw = 1;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
床上的激情91.| 国产精品伊人色| 中文字幕一区av| 国产精品久线观看视频| 欧美精品一区二区三区高清aⅴ| 欧美日韩国产小视频在线观看| eeuss鲁片一区二区三区在线看| 福利一区二区在线| 国产成人av电影在线播放| 国产黄色成人av| 成人手机电影网| av中文字幕一区| 日本韩国精品在线| 在线免费不卡电影| 欧美丰满少妇xxxxx高潮对白| 欧美日韩精品欧美日韩精品一| 欧美日韩一区二区电影| 这里只有精品免费| 精品久久久久久久久久久久久久久久久| 精品国偷自产国产一区| 久久精品视频一区二区| 日本一区二区三区在线不卡| 欧美国产乱子伦| 亚洲一区二区偷拍精品| 日本免费在线视频不卡一不卡二| 久久精品国产99国产精品| 国产福利91精品| 在线视频中文字幕一区二区| 欧美日韩另类国产亚洲欧美一级| 欧美电视剧在线观看完整版| 欧美国产日韩a欧美在线观看| 亚洲人123区| 九色综合狠狠综合久久| 成人激情免费网站| 欧美日韩国产精品成人| 久久久不卡影院| 亚洲综合一二三区| 国产成人自拍在线| 欧美精品三级在线观看| 欧美高清在线一区| 天天色综合成人网| 99综合影院在线| 日韩精品一区二区三区视频| 亚洲天堂成人在线观看| 精品一区二区三区免费观看| 99re66热这里只有精品3直播 | 麻豆91在线播放| 成人小视频免费观看| 91精品婷婷国产综合久久竹菊| 国产日韩欧美激情| 美国十次综合导航| 欧美视频第二页| 最新成人av在线| 国产激情视频一区二区三区欧美| 91超碰这里只有精品国产| 椎名由奈av一区二区三区| 国产一区二区三区高清播放| 欧美日韩免费视频| 亚洲精选视频免费看| 国产一区在线视频| 欧美一区二区三区爱爱| 亚洲 欧美综合在线网络| 91污在线观看| 国产精品每日更新| 国产成人在线色| 久久久精品黄色| 久久精品久久99精品久久| 欧美午夜精品久久久| 成人欧美一区二区三区小说| 成人av网站免费| 欧美激情一区二区在线| 国产盗摄一区二区三区| 国产欧美日韩在线| 成熟亚洲日本毛茸茸凸凹| 久久女同精品一区二区| 精品一区二区国语对白| 日韩欧美在线不卡| 免费av网站大全久久| 91精品国产综合久久蜜臀| 午夜视频久久久久久| 欧美精品第1页| 日韩福利电影在线| 欧美大片在线观看| 久久99精品国产麻豆婷婷洗澡| 日韩视频免费观看高清完整版 | 一区免费观看视频| 99久久国产综合精品麻豆| 亚洲天堂av老司机| 欧美日韩国产中文| 久久成人综合网| 国产三级三级三级精品8ⅰ区| 国产成人综合自拍| 亚洲色欲色欲www在线观看| 色爱区综合激月婷婷| 亚洲国产一区二区在线播放| 欧美电影在哪看比较好| 久久99久久久欧美国产| 国产日韩精品一区二区浪潮av | 欧美精选午夜久久久乱码6080| 日韩成人午夜精品| 久久久久久久久一| 日本精品免费观看高清观看| 婷婷久久综合九色综合伊人色| 精品国产一区二区精华| 成人免费视频一区二区| 一级女性全黄久久生活片免费| 欧美精品久久99久久在免费线| 国产精品一区二区三区99| 亚洲人成在线播放网站岛国| 91精品国产日韩91久久久久久| 国产综合久久久久久鬼色| 亚洲人午夜精品天堂一二香蕉| 精品视频色一区| 国产成人在线看| 亚洲va欧美va人人爽| 精品国产乱码久久久久久蜜臀 | 国产**成人网毛片九色| 一区二区三区在线视频免费| 91精品国产一区二区| 99久久久无码国产精品| 久久成人av少妇免费| 亚洲一区在线观看视频| 久久综合九色综合97_久久久| 色哟哟精品一区| 懂色中文一区二区在线播放| 亚洲777理论| 亚洲美女一区二区三区| 久久新电视剧免费观看| 91精品国产91久久综合桃花| 99国产精品99久久久久久| 国内精品伊人久久久久av一坑| 亚洲精品视频自拍| 久久精品视频免费观看| 日韩三级伦理片妻子的秘密按摩| 91天堂素人约啪| 国产成人精品网址| 美女一区二区在线观看| 亚洲成人动漫av| 亚洲乱码精品一二三四区日韩在线| 精品国产麻豆免费人成网站| 91精品国产综合久久久蜜臀图片| 91香蕉视频污在线| 99久久精品情趣| 成人福利视频在线看| 国产精品69久久久久水密桃| 日日摸夜夜添夜夜添精品视频| 一区二区三区中文在线观看| 亚洲欧美日韩国产中文在线| 亚洲国产成人在线| 国产欧美日韩精品在线| 2019国产精品| 久久女同性恋中文字幕| 久久免费的精品国产v∧| 久久―日本道色综合久久| 精品久久久三级丝袜| 久久久久综合网| 国产亚洲综合在线| 国产精品欧美极品| 专区另类欧美日韩| 亚洲一区二区精品视频| 亚洲va天堂va国产va久| 午夜精品视频一区| 久久精品国产99国产精品| 国内精品免费在线观看| 成人亚洲一区二区一| av一区二区三区四区| 在线看不卡av| 91麻豆精品国产综合久久久久久 | 精品久久久久av影院| 久久综合九色综合欧美98| 亚洲国产精品成人综合 | 亚洲国产日韩精品| 日本一不卡视频| 国产成人aaa| 一本久久精品一区二区 | 久久99精品国产.久久久久久| 另类成人小视频在线| 国产成人精品一区二区三区四区| 99久久综合国产精品| 欧美欧美午夜aⅴ在线观看| 欧美精品一区二区在线播放| 中文字幕欧美区| 亚洲永久免费av| 激情六月婷婷久久| 91在线观看免费视频| 欧美一区二区视频网站| 国产片一区二区三区| 伊人婷婷欧美激情| 久久99久久久久| 色婷婷综合久久| 欧美大肚乱孕交hd孕妇| 日韩毛片视频在线看| 蜜桃精品视频在线| 色综合视频在线观看| 日韩视频免费直播| 亚洲欧美色图小说| 精品一区二区在线看| 在线免费观看日本一区| 国产欧美日韩综合| 青青草国产精品亚洲专区无|