mrf24j40_registers.h 14.9 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462
/*
 * Copyright (C) 2017 Neo Nenaco <neo@nenaco.de>
 * Copyright (C) 2017 Koen Zandberg <koen@bergzand.net>
 *
 * This file is subject to the terms and conditions of the GNU Lesser
 * General Public License v2.1. See the file LICENSE in the top level
 * directory for more details.
 */

/**
 * @ingroup drivers_mrf24j40
 * @{
 *
 * @file
 * @brief Register and command definitions for MRF24J40 devices
 *
 * @author      Neo Nenaco <neo@nenaco.de>
 * @author      Koen Zandberg <koen@bergzand.net>
 */

#ifndef MRF24J40_REGISTERS_H
#define MRF24J40_REGISTERS_H

#ifdef __cplusplus
extern "C" {
#endif


/**
 * @name    SPI access specifiers
 * @{
 */
#define MRF24J40_SHORT_ADDR_TRANS       (0x00)
#define MRF24J40_LONG_ADDR_TRANS        (0x80)
#define MRF24J40_ACCESS_READ            (0x00)
#define MRF24J40_ACCESS_WRITE           (0x01)
#define MRF24J40_ACCESS_WRITE_LNG       (0x10)
#define MRF24J40_ADDR_OFFSET            (0x01)
/** @} */

/**
 * @name    FIFO-Address-Map
 * @{
 */
#define MRF24J40_TX_NORMAL_FIFO         (0x000)
#define MRF24J40_TX_BEACON_FIFO         (0x080)
#define MRF24J40_TX_GTS1_FIFO           (0x100)
#define MRF24J40_TX_GTS2_FIFO           (0x180)
#define MRF24J40_RX_FIFO                (0x300)
/** @} */

/**
 * @name    Short-Register addresses
 * @{
 */
#define MRF24J40_REG_RXMCR              (0x00)
#define MRF24J40_REG_PANIDL             (0x01)
#define MRF24J40_REG_PANIDH             (0x02)
#define MRF24J40_REG_SADRL              (0x03)
#define MRF24J40_REG_SADRH              (0x04)
#define MRF24J40_REG_EADR0              (0x05)
#define MRF24J40_REG_EADR1              (0x06)
#define MRF24J40_REG_EADR2              (0x07)
#define MRF24J40_REG_EADR3              (0x08)
#define MRF24J40_REG_EADR4              (0x09)
#define MRF24J40_REG_EADR5              (0x0A)
#define MRF24J40_REG_EADR6              (0x0B)
#define MRF24J40_REG_EADR7              (0x0C)
#define MRF24J40_REG_RXFLUSH            (0x0D)
#define MRF24J40_REG_ORDER              (0x10)
#define MRF24J40_REG_TXMCR              (0x11)
#define MRF24J40_REG_ACKTMOUT           (0x12)
#define MRF24J40_REG_ESLOTG1            (0x13)
#define MRF24J40_REG_SYMTICKL           (0x14)
#define MRF24J40_REG_SYMTICKH           (0x15)
#define MRF24J40_REG_PACON0             (0x16)
#define MRF24J40_REG_PACON1             (0x17)
#define MRF24J40_REG_PACON2             (0x18)
#define MRF24J40_REG_TXBCON0            (0x1A)
#define MRF24J40_REG_TXNCON             (0x1B)
#define MRF24J40_REG_TXG1CON            (0x1C)
#define MRF24J40_REG_TXG2CON            (0x1D)
#define MRF24J40_REG_ESLOTG23           (0x1E)
#define MRF24J40_REG_ESLOTG45           (0x1F)
#define MRF24J40_REG_ESLOTG67           (0x20)
#define MRF24J40_REG_TXPEND             (0x21)
#define MRF24J40_REG_WAKECON            (0x22)
#define MRF24J40_REG_FRMOFFSET          (0x23)
#define MRF24J40_REG_TXSTAT             (0x24)
#define MRF24J40_REG_TXBCON1            (0x25)
#define MRF24J40_REG_GATECLK            (0x26)
#define MRF24J40_REG_TXTIME             (0x27)
#define MRF24J40_REG_HSYMTMRL           (0x28)
#define MRF24J40_REG_HSYMTMRH           (0x29)
#define MRF24J40_REG_SOFTRST            (0x2A)
#define MRF24J40_REG_SECCON0            (0x2C)
#define MRF24J40_REG_SECCON1            (0x2D)
#define MRF24J40_REG_TXSTBL             (0x2E)
#define MRF24J40_REG_RXSR               (0x30)
#define MRF24J40_REG_INTSTAT            (0x31)
#define MRF24J40_REG_INTCON             (0x32)
#define MRF24J40_REG_GPIO               (0x33)
#define MRF24J40_REG_TRISGPIO           (0x34)
#define MRF24J40_REG_SLPACK             (0x35)
#define MRF24J40_REG_RFCTL              (0x36)
#define MRF24J40_REG_SECCR2             (0x37)
#define MRF24J40_REG_BBREG0             (0x38)
#define MRF24J40_REG_BBREG1             (0x39)
#define MRF24J40_REG_BBREG2             (0x3A)
#define MRF24J40_REG_BBREG3             (0x3B)
#define MRF24J40_REG_BBREG4             (0x3C)
#define MRF24J40_REG_BBREG6             (0x3E)
#define MRF24J40_REG_CCAEDTH            (0x3F)
/** @} */

/**
 * @name    Long-Register addresses
 * @{
 */
#define MRF24J40_REG_RFCON0             (0x200)
#define MRF24J40_REG_RFCON1             (0x201)
#define MRF24J40_REG_RFCON2             (0x202)
#define MRF24J40_REG_RFCON3             (0x203)
#define MRF24J40_REG_RFCON5             (0x205)
#define MRF24J40_REG_RFCON6             (0x206)
#define MRF24J40_REG_RFCON7             (0x207)
#define MRF24J40_REG_RFCON8             (0x208)
#define MRF24J40_REG_SLPCAL0            (0x209)
#define MRF24J40_REG_SLPCAL1            (0x20A)
#define MRF24J40_REG_SLPCAL2            (0x20B)
#define MRF24J40_REG_RFSTATE            (0x20F)
#define MRF24J40_REG_RSSI               (0x210)
#define MRF24J40_REG_SLPCON0            (0x211)
#define MRF24J40_REG_SLPCON1            (0x220)
#define MRF24J40_REG_WAKETIMEL          (0x222)
#define MRF24J40_REG_WAKETIMEH          (0x223)
#define MRF24J40_REG_REMCNTL            (0x224)
#define MRF24J40_REG_REMCNTH            (0x225)
#define MRF24J40_REG_MAINCNT0           (0x226)
#define MRF24J40_REG_MAINCNT1           (0x227)
#define MRF24J40_REG_MAINCNT2           (0x228)
#define MRF24J40_REG_MAINCNT3           (0x229)
#define MRF24J40_REG_TESTMODE           (0x22F)
#define MRF24J40_REG_ASSOEADR0          (0x230)
#define MRF24J40_REG_ASSOEADR1          (0x231)
#define MRF24J40_REG_ASSOEADR2          (0x232)
#define MRF24J40_REG_ASSOEADR3          (0x233)
#define MRF24J40_REG_ASSOEADR4          (0x234)
#define MRF24J40_REG_ASSOEADR5          (0x235)
#define MRF24J40_REG_ASSOEADR6          (0x236)
#define MRF24J40_REG_ASSOEADR7          (0x237)
#define MRF24J40_REG_ASSOSADR0          (0x238)
#define MRF24J40_REG_ASSOSADR1          (0x239)
#define MRF24J40_REG_UPNONCE0           (0x240)
#define MRF24J40_REG_UPNONCE1           (0x241)
#define MRF24J40_REG_UPNONCE2           (0x242)
#define MRF24J40_REG_UPNONCE3           (0x243)
#define MRF24J40_REG_UPNONCE4           (0x244)
#define MRF24J40_REG_UPNONCE5           (0x245)
#define MRF24J40_REG_UPNONCE6           (0x246)
#define MRF24J40_REG_UPNONCE7           (0x247)
#define MRF24J40_REG_UPNONCE8           (0x248)
#define MRF24J40_REG_UPNONCE9           (0x249)
#define MRF24J40_REG_UPNONCE10          (0x24A)
#define MRF24J40_REG_UPNONCE11          (0x24B)
#define MRF24J40_REG_UPNONCE12          (0x24C)
/** @} */

/**
 * @name    Timing definition for the mrf24j40.
 * @{
 */
#define MRF24J40_RESET_DELAY                    (2000U)     /* Datasheet MRF24J40 ~2ms */
#define MRF24J40_RESET_PULSE_WIDTH              (20000U)    /* 20ms (estimated */

#define MRF24J40_WAKEUP_DELAY                   (2000U)
/** Undocumented delay. Probably needed because the bit has to be sampled by the low speed sleep clock */
#define MRF24J40_DELAY_SLEEP_TOGGLE             (50U)
#define MRF24J40_STATE_RESET_DELAY              (200U)
/** @} */

/**
 * @name    Bitfield definitions for the RXMCR register (0x00)
 * @{
 */
#define MRF24J40_RXMCR_NOACKRSP                 (0x20)
#define MRF24J40_RXMCR_PANCOORD                 (0x08)
#define MRF24J40_RXMCR_COORD                    (0x04)
#define MRF24J40_RXMCR_ERRPKT                   (0x02)
#define MRF24J40_RXMCR_PROMI                    (0x01)
/** @} */

/**
 * @name    Bitfield definitions for the RXFLUSH register (0x0D)
 * @{
 */
#define MRF24J40_RXFLUSH_WAKEPOL                (0x40)
#define MRF24J40_RXFLUSH_WAKEPAD                (0x20)
#define MRF24J40_RXFLUSH_CMDONLY                (0x08)
#define MRF24J40_RXFLUSH_DATAONLY               (0x04)
#define MRF24J40_RXFLUSH_BCNONLY                (0x02)
#define MRF24J40_RXFLUSH_RXFLUSH                (0x01)
/** @} */

/**
 * @brief   Bitfield definitions for the TXMCR register (0x11)
 * @{
 */
#define MRF24J40_TXMCR_CSMA_BACKOFF_MASK        (0x07)

#define MRF24J40_TXMCR_MACMINBE                 (0x18)
#define MRF24J40_TXMCR_NOCSMA                   (0x80)
#define MRF24J40_TXMCR_BATLIFEXT                (0x40)
#define MRF24J40_TXMCR_SLOTTED                  (0x20)
#define MRF24J40_TXMCR_MACMINBE1                (0x10)
#define MRF24J40_TXMCR_MACMINBE0                (0x08)
#define MRF24J40_TXMCR_CSMABF2                  (0x04)
#define MRF24J40_TXMCR_CSMABF1                  (0x02)
#define MRF24J40_TXMCR_CSMABF0                  (0x01)

/** @} */

/**
 * @name    Bitfield definitions for the PACON2 register (0x18)
 * @{
 */
#define MRF24J40_PACON2_FIFOEN                  (0x80)
#define MRF24J40_PACON2_TXONTS3                 (0x20)
#define MRF24J40_PACON2_TXONTS2                 (0x10)
#define MRF24J40_PACON2_TXONTS1                 (0x08)
#define MRF24J40_PACON2_TXONTS0                 (0x04)
#define MRF24J40_PACON2_TXONT8                  (0x02)
#define MRF24J40_PACON2_TXONT7                  (0x01)
/** @} */

/**
 * @name    Bitfield definitions for the TXNCON register (0x1B)
 * @{
 */
#define MRF24J40_TXNCON_FPSTAT            (0x10)
#define MRF24J40_TXNCON_INDIRECT          (0x08)
#define MRF24J40_TXNCON_TXNACKREQ         (0x04)
#define MRF24J40_TXNCON_TXNSECEN          (0x02)
#define MRF24J40_TXNCON_TXNTRIG           (0x01)
/** @} */

/**
 * @name    Bitfield definitions for the WAKECON register (0x22)
 * @{
 */
#define MRF24J40_WAKECON_IMMWAKE                (0x80)
#define MRF24J40_WAKECON_REGWAKE                (0x40)
/** @} */

/**
 * @name    Bitfield definitions for the TXSTAT register (0x24)
 * @{
 */
#define MRF24J40_TXSTAT_MAX_FRAME_RETRIES       (0xC0)
#define MRF24J40_TXSTAT_TXNRETRY1               (0x80)
#define MRF24J40_TXSTAT_TXNRETRY0               (0x40)
#define MRF24J40_TXSTAT_CCAFAIL                 (0x20)
#define MRF24J40_TXSTAT_TXG2FNT                 (0x10)
#define MRF24J40_TXSTAT_TXG1FNT                 (0x08)
#define MRF24J40_TXSTAT_TXG2STAT                (0x04)
#define MRF24J40_TXSTAT_TXG1STAT                (0x02)
#define MRF24J40_TXSTAT_TXNSTAT                 (0x01)
/** @} */

/**
 * @name    Shift offsets for TXSTAT register (0x24)
 * @{
 */
#define MRF24J40_TXSTAT_MAX_FRAME_RETRIES_SHIFT (6U)
#define MRF24J40_TXSTAT_CCAFAIL_SHIFT           (5U)
/** @} */

/**
 * @name    Bitfield definitions for the SOFTRST register (0x2A)
 * @{
 */
#define MRF24J40_SOFTRST_RSTPWR                 (0x04)
#define MRF24J40_SOFTRST_RSTBB                  (0x02)
#define MRF24J40_SOFTRST_RSTMAC                 (0x01)
/** @} */

/**
 * @name    Bitfield definitions for the TXSTBL register (0x2E)
 * @{
 */
#define MRF24J40_TXSTBL_RFSTBL3        (0x80)
#define MRF24J40_TXSTBL_RFSTBL2        (0x40)
#define MRF24J40_TXSTBL_RFSTBL1        (0x20)
#define MRF24J40_TXSTBL_RFSTBL0        (0x10)
#define MRF24J40_TXSTBL_MSIFS3         (0x08)
#define MRF24J40_TXSTBL_MSIFS2         (0x04)
#define MRF24J40_TXSTBL_MSIFS1         (0x02)
#define MRF24J40_TXSTBL_MSIFS0         (0x01)
/** @} */

/**
 * @name    Bitfield definitions for the INTSTAT register (0x31)
 * @{
 */
#define MRF24J40_INTSTAT_SLPIF          (0x80)
#define MRF24J40_INTSTAT_WAKEIF         (0x40)
#define MRF24J40_INTSTAT_HSYMTMRIF      (0x20)
#define MRF24J40_INTSTAT_SECIF          (0x10)
#define MRF24J40_INTSTAT_RXIF           (0x08)
#define MRF24J40_INTSTAT_TXG2IF         (0x04)
#define MRF24J40_INTSTAT_TXG1IF         (0x02)
#define MRF24J40_INTSTAT_TXNIF          (0x01)
/** @} */

/**
 * @name    Bitfield definitions for the INTCON register (0x32)
 * @{
 */
#define MRF24J40_INTCON_SLPIE           (0x80)
#define MRF24J40_INTCON_WAKEIE          (0x40)
#define MRF24J40_INTCON_HSYMTMRIE       (0x20)
#define MRF24J40_INTCON_SECIE           (0x10)
#define MRF24J40_INTCON_RXIE            (0x08)
#define MRF24J40_INTCON_TXG2IE          (0x04)
#define MRF24J40_INTCON_TXG1IE          (0x02)
#define MRF24J40_INTCON_TXNIE           (0x01)
/** @} */

/**
 * @name    Bitfield definitions for the SLPACK register (0x35)
 * @{
 */
#define MRF24J40_SLPACK_SLPACK                  (0x80)
/** @} */

/**
 * @name    Bitfield definitions for the RFCTL register (0x36)
 * @{
 */
#define MRF24J40_RFCTL_WAKECNT8         (0x10)
#define MRF24J40_RFCTL_WAKECNT7         (0x08)
#define MRF24J40_RFCTL_RFRST            (0x04)
#define MRF24J40_RFCTL_RFTXMODE         (0x02)
#define MRF24J40_RFCTL_RFRXMODE         (0x01)
/** @} */

/**
 * @name    Bitfield definitions for the BBREG1 register (0x39)
 * @{
 */
#define MRF24J40_BBREG1_RXDECINV                (0x04)
/** @} */

/**
 * @name    Bitfield definitions for the BBREG2 register (0x3A)
 * @{
 */
#define MRF24J40_BBREG2_CCAMODE3                (0xC0)
#define MRF25J40_BBREG2_CCAMODE1                (0x80)
#define MRF24J40_BBREG2_CCAMODE2                (0x40)

#define MRF24J40_BBREG2_CCACSTH                 (0x3C)
/** @} */

/**
 * @name    Bitfield definitions for the BBREG6 register (0x3E)
 * @{
 */
#define MRF24J40_BBREG6_RSSIMODE1               (0x80)
#define MRF24J40_BBREG6_RSSIMODE2               (0x40)
#define MRF24J40_BBREG2_RSSIRDY                 (0x01)

#define MRF24J40_BBREG2_CCACSTH                 (0x3C)
/** @} */

/**
 * @name    Bitfield definitions for the RFCON1 register (0x201)
 * @{
 */
#define MRF24J40_RFCON1_VCOOPT7         (0x80)
#define MRF24J40_RFCON1_VCOOPT6         (0x40)
#define MRF24J40_RFCON1_VCOOPT5         (0x20)
#define MRF24J40_RFCON1_VCOOPT4         (0x10)
#define MRF24J40_RFCON1_VCOOPT3         (0x08)
#define MRF24J40_RFCON1_VCOOPT2         (0x04)
#define MRF24J40_RFCON1_VCOOPT1         (0x02)
#define MRF24J40_RFCON1_VCOOPT0         (0x01)
/** @} */

/**
 * @name    Bitfield definitions for the RFCON2 register (0x202)
 * @{
 */
#define MRF24J40_RFCON2_PLLEN           (0x80)
/** @} */

/**
 * @name    Bitfield definitions for the RFCON6 register (0x206)
 * @{
 */
#define MRF24J40_RFCON6_TXFIL           (0x80)
#define MRF24J40_RFCON6_20MRECVR        (0x10)
#define MRF24J40_RFCON6_BATEN           (0x08)
/** @} */

/**
 * @name    Bitfield definitions for the RFCON7 register (0x207)
 * @{
 */
#define MRF24J40_RFCON7_SLPCLKSEL1      (0x80)
#define MRF24J40_RFCON7_SLPCLKSEL2      (0x40)
/** @} */

/**
 * @name    Bitfield definitions for the RFCON8 register (0x208)
 * @{
 */
#define MRF24J40_RFCON8_RFVCO           (0x10)
/** @} */

/**
 * @name    Bitfield definitions for the RFSTATE register (0x20F)
 * @{
 */
#define MRF24J40_RFSTATE_MASK           (0xA0)
#define MRF24J40_RFSTATE_RTSEL2         (0xE0)
#define MRF24J40_RFSTATE_RTSEL1         (0xC0)
#define MRF24J40_RFSTATE_RX             (0xA0)
#define MRF24J40_RFSTATE_TX             (0x80)
#define MRF24J40_RFSTATE_CALVCO         (0x60)
#define MRF24J40_RFSTATE_SLEEP          (0x40)
#define MRF24J40_RFSTATE_CALFIL         (0x20)
#define MRF24J40_RFSTATE_RESET          (0x00)
/** @} */

/**
 * @name    Bitfield definitions for the SLPCON1 register (0x211)
 * @{
 */
#define MRF24J40_SLPCON0_INTEDGE        (0x02)
#define MRF24J40_SLPCON0_SLPCLKEN       (0x01)
/** @} */

/**
 * @name    Bitfield definitions for the SLPCON1 register (0x212)
 * @{
 */
#define MRF24J40_SLPCON1_CLKOUTEN       (0x20)
#define MRF24J40_SLPCON1_SLPCLKDIV4     (0x10)
#define MRF24J40_SLPCON1_SLPCLKDIV3     (0x08)
#define MRF24J40_SLPCON1_SLPCLKDIV2     (0x04)
#define MRF24J40_SLPCON1_SLPCLKDIV1     (0x02)
#define MRF24J40_SLPCON1_SLPCLKDIV0     (0x01)
/** @} */


#ifdef __cplusplus
}
#endif

#endif /* MRF24J40_REGISTERS_H */
/** @} */