⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hpref_defines.h

📁 nrf24z1 代码
💻 H
字号:
/*= hpref_defines.h ============================================================
 *
 * 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:
 *
 *    Global defines for entire MCU-based system. 
 *    Choose which features to compile into your system.
 *    This file is hardware (ADC, DAC, MCU) independant.
 *
 * Compiler: Tested with WinAVR, avr-gcc (GCC) 3.4.3
 *
 * Revision: 2.0 
 *
 *==============================================================================
 */


// Only include this file once
#ifndef MAIN_H
#define MAIN_H

// MCU speed, may add more definitions here, but they must make sense in mcu_xxxx.c!
//#define MCU_8000                                  // 8MHz internal RC oscillator, doesn't work well with ADC 2-wire setup
//#define MCU_3686                                  // STK500 3.686MHz oscillator, not tried with ADC 2-wire setup
#define MCU_1000                                    // 8MHz internal RC oscillator divided by 8, default option in atmega48/88
//#define ATXDEVBOARD                               // ATX is development board, not finished product platform
//#define ARXDEVBOARD                               // ARX is development board, not finished product platform


// Global project defines let you choose which parts of this program to compile into your
// MCU. Reducing the feature set will reduce the memory requirement.
#define Z12WDEVADR      0b00101001                  // 7-bit nRF24Z1 slave device address with SADR (MSB) = 0 (eval board MZ_ADR = on)
//#define Z12WDEVADR    0b01101001                  // 7-bit nRF24Z1 slave device address with SADR (MSB) = 1 (eval board MZ_ADR = off)
#define TERMINATE_ON_ERROR							// Halt program if an unexpected state occurs
//#define DEBUG                                     // Enable debug information to terminal with UART
#ifdef DEBUG                                        // If the debug system and is enabled, you may choose other debug options
    #define DEBUG2W                                 // Enable debug of 2-wire interface
    //#define DEBUGIF                               // With debug available, you may bypass program and use a hex debug interface   
    //#define DEBUGDAC                              // Report RXEXEC status from DAC writes
    #define Z1UI                                    // Enable singlewrite debug of nRF24Z1 ATX in hex user interface - default option - or...
    //#define ADCUI                                 // Enable singlewrite debug of ADC in hex user interface; or...
    //#define DACUI                                 // Enable singlewrite debug of DAC in hex user interface    
#endif
#define Z1INTERRUPT                                 // Enable interrupt from nRF24Z1 to MCU
#define Z1ALTERADDRESS                              // Enable address changes


// Product user interface / MMI definitions (leave buttons bit definitions unchanged for compatibility mode)
#define USELED                                      // Use LEDs
#ifdef USELED
    #define LEDON           0x01                    // The LED is on
    #define LEDOFF          0x00                    // The LED is off
    #define LED_INITIAL     0b1111111111111111;     // At startup, before establishing a link, keep lights on
    #define LED_FAILURE     0b0001000100010001;     // If program failed, blink in a fast on-off-on-off-on-off pattern 
    #define LED_AWAKE       0b1010000000000000;     // When streaming audio, blink twice, then keep lights off for a long time
    #define LED_POWERDOWN   0b1000000010000000;     // When user selected sleep mode, blink once, then keep lights off for a long time
    #define LED_AUTODOWN    0b1000000010000000;     // When the system went to automatic power down, blink once, then keep lights off for a little while
#endif
#define BTN_NOKEY           0b00000000              // No button pressed on user interface
#define BTN_PLAY            0b00000010              // Play, pause, power on
#define BTN_VOLUP           0b00001000              // Volume up button
#define BTN_VOLDN           0b00000100              // Volume down button
#define BTN_STOP            0b00000001              // Stop and turn power off
#define BTN_SKIPF           0b00000011              // Skip forwards button
#define BTN_SKIPB           0b00000101              // Skip backwards button
#define BTN_SCANF           0b00001110              // Scan forwards button
#define BTN_SCANB           0b00000111              // Scan backwards button
#define BTN_BBOOST          0b00001001              // Bass boost button
#define BTN_RECON           0b00001010              // Reconnect button
#define BTN_POWER           0b00001011              // Power button
#define BTN_MUTE            0b00001100              // Mute audio output
// Application dependant button definitions
#define BTN_AUX1            0b00001101              // AUX1 button
#define BTN_AUX2            0b00000110              // AUX2 button
#define BTN_AUX3            0b00001111              // AUX3 button


// nRF24Z1 I/O definitions
#define LINKFINDCOUNTER     32                      // How may times should user interface options 1 and 3 look for a link after Play is pressed?
#define LINKFINDPERIOD      32                      // How long time should it wait each time between looking for a link?
#define MAXPOLLITER         100                     // Flag poll cycles before timeout is declared
#define POLLDURATION        4                       // Number of ms to wait at the end of an unsuccessfull poll cycle
#define FLAGREADY           0x00                    // 0x00 indicates that an nRF24Z1 flag/transfer register is ready
#define Z1TIMEOUT           0x02                    // 0x02 indicates nRF24Z1 internal timeout = prev. data failed but ready for new data
#define OKAY                0x00                    // Error/result reports that all is well
#define TIMEOUT             0xFF                    // Error/result reports that something timed out
#define LINKPRESENT         0x01                    // A link is there!
#define SPDIF               0x00                    // Select S/PDIF as digital audio interface
#define I2S                 0x01                    // Select I2S as digital audio interface
#define MUTEON              0x00                    // Turn on ARX muting
#define MUTEOFF             0x01                    // Turn off ARX muting


// Power down definitions used by main_optionX.c
#define PMODE_AWAKE         0x00                    // Awake
#define PMODE_POWERDOWN     0x01                    // In power down mode
#define PMODE_AUTODOWN      0x02                    // ATX nRF24Z1 went to automatic power down
#define WAKE_Z1_INT         0x00                    // Woke up from nRF24Z1 interrupt
#define WAKE_WAIT           0x01                    // Woke up from internal wait timer
// Interrupt definitions
#define INT_VOID            0x00                    // No interrupt
#define INT_LBROKEN         0x40                    // Interrupt if link is broken
#define INT_LQUAL           0x20                    // Interrupt if link quality if poor
#define INT_RTRANS          0x10                    // Interrupt if remote transfer is done
#define INT_RINPUT          0x08                    // Interrupt if remote input changed
#define INT_LERROR          0x04                    // Interrupt if link error is high
#define INT_WAKE            0x02                    // Interrupt if wake from power down


// nRF24Z1 internal register names
// Config states
#define C_OPEN              0x00                    // Registers open
#define C_CLOSED            0x01                    // Registers closed
#define C_TIMEOUT           0x02                    // Registers timed out

// STATUS:
#define TXSTA               0x01
#define INTSTA              0x02
#define LNKSTA              0x03
#define LNKQ                0x04
#define LNKERR              0x05
#define RXSTAT              0x06
#define RXPIN               0x07

// LINK:
#define CH0                 0x0C
#define CH1                 0x0D
#define CH2                 0x0E
#define CH3                 0x0F
#define CH4                 0x10
#define CH5                 0x11
#define CH6                 0x12
#define CH7                 0x13
#define CH8                 0x14
#define CH9                 0x15
#define CH10                0x16
#define CH11                0x17
#define CH12                0x18
#define CH13                0x19
#define CH14                0x1A
#define CH15                0x1B
#define CH16                0x1C
#define CH17                0x1D
#define CH18                0x1E
#define CH19                0x1F
#define CH20                0x20
#define CH21                0x21
#define CH22                0x22
#define CH23                0x23
#define CH24                0x24
#define CH25                0x25
#define CH26                0x26
#define CH27                0x27
#define CH28                0x28
#define CH29                0x29
#define CH30                0x2A
#define CH31                0x2B
#define CH32                0x2C
#define CH33                0x2D
#define CH34                0x2E
#define CH35                0x2F
#define CH36                0x30
#define CH37                0x31
#define BCHD                0x32
#define NBCH                0x33
#define NACH                0x34
#define NLCH                0x35
#define LNKMOD              0x36
#define LNKWTH              0x37
#define LNKETH              0x38
#define ADDR_0              0x39 
#define ADDR_1              0x3A
#define ADDR_2              0x3B
#define ADDR_3              0x3C
#define ADDR_4              0x3D
#define LINKCSTATE          0x3E

// RX CONFIG:
#define RXRESO              0x40
#define RXPIO               0x41
#define RXPWME              0x42
#define RXPWMD              0x43
#define I2SCNF_OUT          0x44
#define RXWAKE              0x45
#define RXSTI_0             0x46
#define RXSTI_1             0x47
#define RXWTI               0x48
#define RXPWR               0x49
#define RXMOD               0x4A 
#define RXCSTATE            0x4B
#define RXLTI               0x4C
#define TXLTI               0x4D

// TX CONFIG:
#define TXRESO              0x50
#define TXFMT               0x51
#define TXLAT               0x52
#define INTCF               0x53
#define I2SCNF_IN           0x54
#define I2SRAT              0x55
#define TXPWR               0x56
#define TXSTI_0             0x57
#define TXSTI_1             0x58
#define TXWTI               0x59
#define TXMOD               0x5A
#define TXCSTATE            0x5B

// RX BUFFER
#define RXBUF_0             0x60
#define RXBUF_1             0x61
#define RXBUF_2             0x62
#define RXBUF_3             0x63
#define RXBUF_4             0x64
#define RXBUF_5             0x65
#define RXBUF_6             0x66
#define RXBUF_7             0x67
#define RXBUF_8             0x68
#define RXBUF_9             0x69
#define RXBUF_10            0x6A
#define RXBUF_11            0x6B
#define RXBUF_12            0x6C
#define RXBUF_13            0x6D
#define RXBUF_14            0x6E
#define RXBUF_15            0x6F

// RX COMMAND:
#define RXDCMD              0x70
#define RXWCNT              0x71
#define RXRCNT              0x72
#define RXEXEC_ID           0x73
#define RXEXEC              0x74

#define TXDD                0x75

#define REV                 0x7D
#define TESTREG             0x7E
#define TESTCH              0x7F


// Local includes
#include "mcu.h"
#include "dac.h"
#include "adc.h"
#include "z1slaveio.h"
#ifdef DEBUG
#include "uartdebug.h"
#endif


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -