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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? main_option2.c

?? nrf24z1 代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*= main_option2.c =============================================================
 *
 * Copyright (C) 2005 Nordic Semiconductor
 *
 * This file is distributed in the hope that it will be useful, but WITHOUT
 * WARRANTY OF ANY KIND.
 *
 * Author(s): Borge Strand
 *
 * Description:
 *
 *    Startup, address generation, user interface for user interface option 2
 *    with soft power on only at ARX 
 *
 * Compiler: Tested with WinAVR, avr-gcc (GCC) 3.4.3
 *
 * Revision: 2.0 
 *
 *==============================================================================
 */


// This program sets up a private address for ARX and ATX, puts the system into sleep mode, and
// runs the user interface. After batteries are inserted and the on/off button is flipped to "ON", 
// the user must press and hold the ARX Play button for music to appear. The time the Play button
// has to be held depends on the aggressiveness of the time-division-multiplexing used in sleep mode;
// lower current consumption trades against the Play button having to be held for a longer time in
// order to turn on the system.
// This program receives all compatible buttons possible from both ATX and ARX user interfaces
// Fill in here how different button commands are to be passed to the audio source system. This 
// program only executes DAC volume control and nRF24Z1 power up/down.

// Certain parameters in z1config must be changed to work with this file. After restoring factory 
// default settings, please make the following alterations for user interface option 1:
//
// Link:
// LNKETH=0x20
// LNKMOD=0x08, Mute when LNKERRLNKETH
// NLCH=0x0F
// ADDR, use your preferred initial address. This address must match that of function z1_setinitialadr().
//
// Interrupts:
// INTCF=0x02, Enable wakeup from power down interrupt
//
// ATX:                                             ARX:
// I2SCNF_IN=0x80, Audio mode = Master mode         RXSTA=0x40, Disable serial slave interface
// TXLAT=0x04, Nominal, 20ms @ 48kHz                RXWTI=0x02
// TXWTI=0x02                                       RXLTI=0x4A
// TXLTI=0x4A                                       RXSTI=0x0000
// TXSTI=0x0030                                     RXWAKE=0x02, Wakeup on DI[1] change
// TXMOD=0x82, RF, I2S, 44.1                        I2SCNF_OUT=0x40, Mute sound
//                                                  RXMOD=0xA0, RF, I2S, RX power down

#define SLEEP_TXWTI     0x02                        // ATX is awake for 0x03 * 10ms = 30ms, ATX may go to auto power down
#define SLEEP_TXSTI_0   0x30                        // ATX is asleep for 0x30 * 10ms = 480ms
#define SLEEP_TXSTI_1   0x00
#define SLEEP_TXLTI     0x4A                        // ATX powers down after 0x02 * (0x4A + 1) * 10ms = 1500ms without link

#define SLEEP_RXWTI     0x02                        // ARX may go to auto power down
#define SLEEP_RXSTI_0   0x00                        // ARX sleep timer is not used, ARX is wake-on-interrupt
#define SLEEP_RXSTI_1   0x00
#define SLEEP_RXLTI     0x4A                        // Auto power down after 0x02 * (0x4A + 1) * 10ms = 1500ms without link, = on-time after button chg
#define SLEEP_RXWAKE    0x02                        // ARX wakes up from Play button, see button definitions in hpref_defines.h


int main(void) {
    char booterror = 0;                             // Wheter or not a certain while loop is to execute, 0 means successfull complesion of bootup step
    char debounce = 1;                              // Check buttons before accepting them
    char buttons;                                   // Which button is pressed?
    char powermode;                                 // The power up/down status of the nRF24Z1
    char muted = 0;                                 // Simulate Play/Pause button by muting and unmuting audio while retaining audio link

    #ifdef USELED
        char ledtemp, ledstatus = LEDON;            // Two registers used to track blink sequences of LEDs
    
        ledsequence = LED_INITIAL;                  // Blink according to linkup pattern
        mcu_atxled(z1_rotate_led());                // Left-rotate the led sequence and apply ATX light according to MSB
    #endif

    mcu_init();                                     // Initialize MCU
    mcu_2w_master_init();                           // Enable 2-wire slave interface to nRF24Z1

    #ifdef DEBUG                                    // If debug system is enabled, 
        mcu_uart_init();                            // Turn on UART for debug
        db_putenter();
        mcu_putchar('-');                           // Print welcome message
        mcu_putchar('D');
        mcu_putchar('E');
        mcu_putchar('V');
        mcu_putchar('-');
        db_putenter();
    #endif
    #ifdef DEBUGIF
        db_hex();                                   // Run debug interface if that is defined
    #endif

    volume      = 0xFF;                             // Volume is not initiated, dac_init() gives default value
    bass        = 0xFF;                             // Bass boost is not initiated, dac_init() gives default value, not used in HP ref design

    mcu_z1int_enable();                             // Turn on MCU'c interrupt to ATX nRF24Z1, wakeup from power down int. enabled in nRF24Z1 EEPROM

    // At this stage ATX is just turned on. ARX may be on or off. In any case, do not make any attempt at disabling the ARX DAC. 
    // Instead disable ATX resources (including ADC) and start looking for a link. 

    adc_init();                                     // nRF24Z1 eval kit has instant-on ADC, headphone reference design ADC needs init routine
    adc_sleep();                                    // ADC should not consume power while trying to establish link
    
    // ATX sleeps with wake-on-timer and gives out interrupt. Use that to look for link
    // In user interface option 2, the loop is terminated when Play is pressed on ARX.  
    
    // At this point in the code, the ATX is on because it was configured to do auto power down, and has not shut down
    // yet. Thus it is ready to receive on the 2-wire interface the command to wake up the ARX. During the link search loop below, 
    // both units have to be ready to establish a link. However, the ARX must go straight to power down and not be awake
    // for some time before going to auto power down. That is because the only wakeup souorce for the ARX is the user
    // pressing the ARX Play button. Linkup during ATX's initial waiting-to-go-to-auto-power-down is not allowed.
    
    z1_singlewrite(RXMOD, z1_singleread(RXMOD) & ~0x80);    // We are ready to wake up ARX when we receive a link attempt from it
    
    while (booterror == 0) {
        #ifdef USELED
            mcu_atxled(z1_rotate_led());            // Left-rotate the led sequence and apply ATX light according to MSB
        #endif

        // In option 2 wait for a link attempt from ARX.
        while ((mcu_z1int_active()) && (booterror == 0)) {  // If ATX is alive, keep polling for a link
            if (z1_haslink())                       // check if a link has been established, if it has
                booterror = 1;                      // Terminate this while loop. loop == 0 indicates this step OK in bootup process
        }
        if (booterror == 0)                         // If no link was established, wait to poll again
            mcu_wait_ms(320);                       // Wait routine is terminated either by interrupt or elapsed period
    }   

    booterror = 0;                                  // Loop ended, prepare to continue bootup process

    // A link now exists between ATX and ARX on the initial address. The next thing to do is pick a random private address and
    // put the DAC into the correct power mode. For user interface option 2, we got to this stage through user interaction,
    // and the DAC should be powered on. Also, the ARX nRF24Z1 should stop muting its digital audio output.
    
    // This code assumes that all units are produced equally and therefore have the same initial address loaded from EEPROM. The next
    // section of the code will pick a new address and transfer that to the ARX. The link will then be re-established with the new
    // private address. If, instead, your products are made in individual pairs, this section may be commented out. Picking a random
    // private address is done with the I2S bitclock as a randomness source. This means that the audio clock and the MCU clock must be 
    // asynchronous. It also means that the I2S interface must be operational. In the headphone reference design, nRF24Z1 ATX is I2S 
    // master. There is therefore no need to start up the ADC in order to generate the bitclock from the master clock.
    
    // With units powered up, change from initial to private address

    if (z1_flagready(LINKCSTATE) == OKAY) {         // If ATX is ready bo buffer private address
        z1_setprivateadr();                         // Draw a new private address, write it to ATX, Important: I2S bitclock must be active now!!
        z1_setflag(LINKCSTATE);                     // Tell ATX to relink with privately connected ARX
        mcu_wait_ms(32);                            // Give it some time to relink
    }
    else {                                          // LINKCSTATE was not ready to transfer a new address. Halt bootup process
        booterror = 1;
    }

    if (booterror == 0) {
        if (z1_haslink() == 0) {
            booterror = 1;
        }
    }

    // Done setting up the private address. Now that a link was established, set up the ARX DAC

    if (booterror == 0) {                           // If no error detected, 
        if (dac_init() != OKAY) {                   // Try to initialize DAC
            booterror = 1;                          // If that failed, stop bootup code
        }
    }
    
    // With full user interface either on ARX, user interaction was needed to bring the system up. Therefore: power up
    // all units and run the user interface. 
    
    // Insert code to start music on audio source here!
    
    adc_wake();                                     // Wake up ATX resources 
    
    if (booterror == 0) {                           // If no error detected, 
        if (dac_wake() != OKAY) {                   // Try to wake up DAC
            booterror = 1;                          // If that failed, stop bootup code
        }
    }

    if (booterror == 0) {                           // If no error detected, 
        if (z1_arx_mute(MUTEOFF) != OKAY) {         // Try to unmute ARX
            muted = 0;                              // Simulate play/pause button
            booterror = 1;                          // If that failed, stop bootup code
        }
    }
    
    // Right before the link-finding loop above the power down bit in RXMOD was cleared. The power down bit in TXMOD
    // was never set in EEPROM. TXMOD and RXMOD were both set for auto power down enable. Thus the devices
    // are now in awake mode and no modifications to any mode variables is needed before running the user interface.
    
    #ifdef USELED
        ledsequence = LED_AWAKE;                    // Blink in a pattern indicating audio streaming 
    #endif

    powermode = PMODE_AWAKE;                        // And indicate a power up of ATX


    // Run product interface by polling buttons on TX and RX unit

    while (booterror == 0) {                            
        // Buttons on ARX are hardwired to GPI pins DI[0:3] or written into RXPIN on ARX according to the table 
        // in hpref_defines.h. Buttons on ATX are translated in mcu_xxxx.c from the actual hardware I/O pins on the MCU
        // to a key code equal to the hardware key codes defined for ARX. The key codes are then processed in 
        // this file. All buttons on DI[0:3] are active high. Key codes comprising more than one high bit must
        // be generated by an ARX MCU or diode network. Unused ARX DI[0:3] pins must be tied to ground.
        // This part of the MCU program uses key polling and a low-power wait state. 
    
        if (powermode == PMODE_AUTODOWN)            // Auto power down was detected. Poll interrupt bit for power up
            mcu_wait_ms(320);
        else if (powermode == PMODE_POWERDOWN)      // Controlled power down, ATX nRF24Z1 internal timer must wake up MCU 
            mcu_wait_ms(6400);                      // If that fails, wait 6.4 seconds before investigating
        if (powermode == PMODE_AWAKE)               // Audio streaming mode, MCU polls for input from user interface 
            mcu_wait_ms(64);

        // There are six combinations of variables powermode and wakeup. These six combinations are summarized below.

        //// USER INTERFACE OPTION 2 //// ATX is wake-on-timer, ARX is wake-on-interrupt
        //              |   powermode ==        |   powermode ==            |   powermode == 
        //              |   PMODE_AUTODOWN      |   PMODE_POWERDOWN         |   PMODE_AWAKE
        //              |                       |                           |
        // wakeup ==    |   Check if user       |   ATX is momentarily      |   ATX went to auto 
        // WAKE_Z1_INT  |   pressed Play on ARX |   awake, check for        |   power down
        //              |   and thus got a      |   link attempt from ARX   |
        //              |   radio link, use     |                           |
        // wakeup ==    |   semi-fast polling   |   ATX did not generate    |   Audio streaming mode,
        // WAKE_WAIT    |   in MCU              |   interrupt in time!      |   MCU polls user interfaces
        
        if (powermode == PMODE_AUTODOWN) {
            // It was detected that nRF24Z1 went to auto power down. If this mode was registered, both the MCU timer and the 
            // ATX nRF24Z1 interrupt will wake the MCU in option 2. Going to auto power down, both TXMOD and RXMOD were set 
            // for audio streaming. Therefore there is no need to clear the sleep enable bits in TXMOD and RXMOD when exiting 
            // auto power down. 
                
            // ATX is wake-on-timer. In option 2 check if it was able to relink with ARX after user pressed Play on ATX
            if (mcu_z1int_active()) {               // Check if nRF24Z1 is ready to receive SPI or 2-wire commands
                if (z1_haslink()) {                 // Check if nRF24Z1 came online after auto power down

                    // Instruct your audio source to commence playing music here!

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产高清亚洲一区| 91亚洲国产成人精品一区二区三 | 国产精品成人免费精品自在线观看| 免费视频一区二区| 日韩精品一区二区三区蜜臀| 亚洲一二三四在线观看| 色综合色综合色综合色综合色综合 | 日韩欧美一区二区免费| 精品在线亚洲视频| 久久精品亚洲精品国产欧美kt∨| 国模大尺度一区二区三区| 国产三级精品在线| 91色porny在线视频| 亚洲一区在线观看免费| 91麻豆精品91久久久久久清纯 | 91首页免费视频| 亚洲国产精品一区二区www| 欧美剧情电影在线观看完整版免费励志电影 | 中文字幕精品一区二区三区精品| 波多野结衣91| 蜜臀av在线播放一区二区三区| 久久精品一区二区三区四区| 欧美中文字幕亚洲一区二区va在线 | 久久综合九色综合97_久久久| 国产高清在线观看免费不卡| 亚洲国产欧美一区二区三区丁香婷| 3d动漫精品啪啪1区2区免费 | 免费久久99精品国产| 国产亚洲综合在线| 在线一区二区三区做爰视频网站| 精品亚洲欧美一区| 亚洲午夜免费电影| 久久午夜老司机| 欧美老人xxxx18| 91免费版在线| 国产成人高清视频| 日韩成人免费电影| 一区免费观看视频| 久久亚洲精品国产精品紫薇| 91麻豆精品国产91久久久使用方法| 国产高清久久久久| 韩国成人福利片在线播放| 一区二区日韩av| 亚洲激情男女视频| 中文字幕第一页久久| 国产亚洲午夜高清国产拍精品| 欧美一区二区三区小说| 欧美日韩和欧美的一区二区| 成人中文字幕在线| 国产成人在线影院| 91在线播放网址| 欧美亚洲国产怡红院影院| 欧美亚洲国产一区二区三区va| 色8久久人人97超碰香蕉987| 欧美性感一区二区三区| 欧美精品成人一区二区三区四区| 欧美一二区视频| 欧美极品aⅴ影院| 亚洲精品视频免费看| 视频一区二区中文字幕| 国产精品自拍av| 成人av动漫网站| 日韩欧美国产精品| 欧美一级欧美三级在线观看| 久久亚洲一区二区三区四区| 久久九九全国免费| 亚洲天堂成人网| 激情文学综合网| 91麻豆国产在线观看| 欧美一区二区三区视频在线| 精品处破学生在线二十三| 日韩精品久久理论片| 懂色av一区二区夜夜嗨| 欧美人xxxx| 中文字幕在线不卡一区二区三区 | 欧美日韩日本视频| 精品福利一区二区三区免费视频| 国产精品人成在线观看免费| 日韩av高清在线观看| av亚洲精华国产精华精华| 51精品国自产在线| 亚洲黄色片在线观看| 成人免费毛片aaaaa**| 欧美mv日韩mv| 免费在线视频一区| 欧美午夜精品免费| 亚洲欧美激情小说另类| 91丨porny丨蝌蚪视频| 国产蜜臀av在线一区二区三区| 日韩一区精品字幕| 在线不卡一区二区| 亚洲一区二区在线免费观看视频| 懂色av一区二区夜夜嗨| 精品国产1区二区| 国产精品996| 国产精品久久久久影院| 国产91丝袜在线18| 国产精品二三区| 欧美在线你懂得| 午夜精品一区二区三区三上悠亚 | 欧美日韩亚洲另类| 日本不卡不码高清免费观看| 日韩精品一区二区三区四区视频| 韩国成人在线视频| 国产精品久久久爽爽爽麻豆色哟哟| 成人动漫一区二区| 亚洲自拍偷拍av| 日韩精品综合一本久道在线视频| 国产在线不卡一卡二卡三卡四卡| 久久精品免视看| 欧美综合久久久| 另类调教123区| 国产精品美女www爽爽爽| 欧美美女激情18p| 国产精品99久久久久久宅男| 亚洲五月六月丁香激情| 2023国产一二三区日本精品2022| 91视频免费看| 日本亚洲欧美天堂免费| 久久99久久精品欧美| 亚洲精品一卡二卡| 国产欧美日产一区| 91精品国产综合久久香蕉的特点| 99久久久国产精品| 狠狠色狠狠色合久久伊人| 亚洲欧美日韩系列| 国产精品丝袜一区| 国产丝袜美腿一区二区三区| 欧美剧情电影在线观看完整版免费励志电影 | 国产精品一线二线三线精华| 亚洲一区精品在线| 欧美高清在线一区二区| 欧美一区二区二区| 色哟哟日韩精品| 99精品欧美一区| 国产91丝袜在线观看| 九九九久久久精品| 亚洲成a人v欧美综合天堂下载| 国产精品色一区二区三区| 精品免费国产一区二区三区四区| 欧美天天综合网| 日本韩国欧美在线| 日本久久一区二区三区| 在线观看视频一区| 91精品国产乱| 91精品福利在线一区二区三区| 欧美巨大另类极品videosbest | 91黄色小视频| 欧美人妖巨大在线| 欧美一区二区在线免费观看| 日韩欧美久久一区| 国产欧美一区二区精品秋霞影院| 久久久久久久网| 国产蜜臀97一区二区三区| 久久综合五月天婷婷伊人| 国产精品电影院| 日韩中文字幕1| 国产精品一区二区三区四区| 国产精品99久久久久久久女警 | 免费观看久久久4p| 免费日韩伦理电影| 成人av网站在线| 91精品国产综合久久福利| 久久日韩精品一区二区五区| 欧美激情一区二区三区四区| 国产精品久久三| 五月天网站亚洲| 国产v日产∨综合v精品视频| 欧美日韩国产色站一区二区三区| 日韩欧美在线不卡| 国产欧美一区二区在线观看| 最新中文字幕一区二区三区| 亚洲国产高清aⅴ视频| 日本一区二区成人在线| 亚洲一区二区偷拍精品| 日韩二区三区在线观看| 99国产精品国产精品毛片| av一区二区三区在线| 国产成人综合网| 色美美综合视频| 欧美一卡二卡三卡| 国产精品久久久久久久第一福利 | 午夜精品影院在线观看| 久久99国产精品久久99| 95精品视频在线| 国产精品传媒入口麻豆| 蜜桃视频在线观看一区| 欧美二区在线观看| 亚洲成人av一区二区| 在线观看免费亚洲| 亚洲综合一二三区| 色综合久久久久网| 亚洲女厕所小便bbb| 99久久精品免费看| 中文av字幕一区| 国产精品99久久久久久宅男| 日韩一区二区视频在线观看| 日产欧产美韩系列久久99| 日韩一区二区三区精品视频| 日本午夜一本久久久综合|