From f609cb0f7cc0da778cef832bff25dd0bf00a294b Mon Sep 17 00:00:00 2001 From: nifi Date: Thu, 24 Jun 2010 11:25:07 +0000 Subject: [PATCH] Added macro to read from CC2420 RAM --- core/dev/cc2420.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/core/dev/cc2420.h b/core/dev/cc2420.h index a9ba208bb..3a1008024 100644 --- a/core/dev/cc2420.h +++ b/core/dev/cc2420.h @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: cc2420.h,v 1.11 2010/06/24 09:28:39 nifi Exp $ + * $Id: cc2420.h,v 1.12 2010/06/24 11:25:07 nifi Exp $ */ /** @@ -178,6 +178,20 @@ void cc2420_set_cca_threshold(int value); CC2420_SPI_DISABLE(); \ } while(0) +/* Read from RAM in the CC2420 */ +#define CC2420_READ_RAM(buffer,adr,count) \ + do { \ + uint8_t i; \ + CC2420_SPI_ENABLE(); \ + SPI_WRITE(0x80 | (adr & 0x7f)); \ + SPI_WRITE(((adr >> 1) & 0xc0) | 0x20); \ + SPI_RXBUF; \ + for(i = 0; i < (count); i++) { \ + SPI_READ(((uint8_t*)(buffer))[i]); \ + } \ + CC2420_SPI_DISABLE(); \ + } while(0) + /* Read status of the CC2420 */ #define CC2420_GET_STATUS(s) \ do { \