[Wsim-commits] r826 - arch/msp430 devices/cc1100_2500 platforms/ez430chronos

bernharddick at users.gforge.inria.fr bernharddick at users.gforge.inria.fr
Lun 12 Mar 15:05:34 CET 2012


Author: bernharddick
Date: 2012-03-12 15:05:34 +0100 (Mon, 12 Mar 2012)
New Revision: 826

Added:
   devices/cc1100_2500/cc1101mm_dev.c
   devices/cc1100_2500/cc1101mm_dev.h
Modified:
   arch/msp430/msp430.c
   arch/msp430/msp430.h
   arch/msp430/msp430_intr.c
   arch/msp430/msp430_models.h
   devices/cc1100_2500/Makefile.am
   devices/cc1100_2500/cc1100_2500_dev.c
   devices/cc1100_2500/cc1100_2500_gdo.c
   devices/cc1100_2500/cc1100_2500_globals.h
   devices/cc1100_2500/cc1100_2500_internals.h
   devices/cc1100_2500/cc1100_2500_registers.c
   devices/cc1100_2500/cc1100_2500_state.c
   platforms/ez430chronos/Makefile.am
   platforms/ez430chronos/ez430chronos.c
Log:
- add cc1101 memory mapped definition (for cc430)
- add cc1101mm to the ez430chronos platform


Modified: arch/msp430/msp430.c
===================================================================
--- arch/msp430/msp430.c	2012-03-11 22:50:34 UTC (rev 825)
+++ arch/msp430/msp430.c	2012-03-12 14:05:34 UTC (rev 826)
@@ -207,6 +207,10 @@
   msp430_lcd_create();
   msp430_lcdb_create();
   msp430_rtc_create();
+  
+#if defined(__msp430_have_cc1101)
+  cc1101mm_create();
+#endif
 
 
   MCU_CLOCK.lfxt1_freq = xt1;
@@ -295,6 +299,9 @@
   msp430_lcd_reset();
   msp430_lcdb_reset();
   msp430_rtc_reset();
+#if defined(__msp430_have_cc1101)
+  cc1101mm_reset();
+#endif
 
 #if defined(SOFT_INTR)
   MCU.soft_intr         = 0;
@@ -354,6 +361,12 @@
 void mcu_update_done()
 {
   uint32_t signal;
+  
+#if defined(__msp430_have_cc1101)
+  /* radio update must be done at end of peripheral evaluation */
+  cc1101mm_update();
+#endif
+  
   /* timers capture operations                    */
   msp430_timerA_capture();
   msp430_timerB_capture();

Modified: arch/msp430/msp430.h
===================================================================
--- arch/msp430/msp430.h	2012-03-11 22:50:34 UTC (rev 825)
+++ arch/msp430/msp430.h	2012-03-12 14:05:34 UTC (rev 826)
@@ -46,6 +46,10 @@
 #include "msp430_portmap.h"
 #include "msp430_rtc.h"
 
+#if defined(__msp430_have_cc1101)
+#include "devices/cc1100_2500/cc1101mm_dev.h"
+#endif
+
   /**
    * 0x0ffff
    *    interrupt vector table
@@ -233,6 +237,10 @@
 #if defined(__msp430_have_rtc)
   struct msp430_rtc_t          rtc;
 #endif
+  
+#if defined(__msp430_have_cc1101)
+  struct _msp430_cc1101_t xx_cc1101;
+#endif
 
 #if defined(SOFT_INTR)
   int      soft_intr;
@@ -258,6 +266,7 @@
 #define MCU_FLASH          MCU.flash
 #define MCU_RAM            MCU.ram
 #define MCU_DMA            MCU.dma
+#define MCU_RFCC1101       MCU.xx_cc1101
 
 #if defined(__msp430_have_basic_clock)
 #define MCU_CLOCK          MCU.basic_clock

Modified: arch/msp430/msp430_intr.c
===================================================================
--- arch/msp430/msp430_intr.c	2012-03-11 22:50:34 UTC (rev 825)
+++ arch/msp430/msp430_intr.c	2012-03-12 14:05:34 UTC (rev 826)
@@ -308,6 +308,9 @@
 #if defined(__msp430_have_dac12)
   res |= msp430_dac12_chkifg();
 #endif
+#if defined(__msp430_have_cc1101)
+  res |= cc1101mm_chkifg();
+#endif
 
   return res;
 }

Modified: arch/msp430/msp430_models.h
===================================================================
--- arch/msp430/msp430_models.h	2012-03-11 22:50:34 UTC (rev 825)
+++ arch/msp430/msp430_models.h	2012-03-12 14:05:34 UTC (rev 826)
@@ -630,6 +630,13 @@
 #define __msp430_have_rtc
 #define __msp430_have_new_sfr
 #define __msp430_have_new_uscib
+#define __msp430_have_cc1101
+#if !defined(CC1100)
+#define CC1100
+#endif
+#if !defined(CC1101MM)
+#define CC1101MM
+#endif
 
 // Flash erase timings
 #define FLASH_WRITE_TIMING_BYTE       30

Modified: devices/cc1100_2500/Makefile.am
===================================================================
--- devices/cc1100_2500/Makefile.am	2012-03-11 22:50:34 UTC (rev 825)
+++ devices/cc1100_2500/Makefile.am	2012-03-12 14:05:34 UTC (rev 826)
@@ -1,5 +1,5 @@
 
-noinst_LIBRARIES=libcc1100.a libcc2500.a
+noinst_LIBRARIES=libcc1100.a libcc2500.a libcc1101mm.a
 
 INCLUDES=-I$(top_srcdir)
 
@@ -16,3 +16,6 @@
 
 libcc2500_a_CFLAGS= -DCC2500
 libcc2500_a_SOURCES=$(CC1100_2500)
+
+libcc1101mm_a_CFLAGS= -DCC1100 -DCC1101MM -DCC430f6137
+libcc1101mm_a_SOURCES=$(CC1100_2500) cc1101mm_dev.c cc1101mm_dev.h

Modified: devices/cc1100_2500/cc1100_2500_dev.c
===================================================================
--- devices/cc1100_2500/cc1100_2500_dev.c	2012-03-11 22:50:34 UTC (rev 825)
+++ devices/cc1100_2500/cc1100_2500_dev.c	2012-03-12 14:05:34 UTC (rev 826)
@@ -418,6 +418,9 @@
 
 int cc1100_io_pins (struct _cc1100_t *cc1100) 
 {
+#if defined(CC1101MM)
+  return 0;
+#endif
 	
   if (cc1100_read_pin(cc1100, CC1100_INTERNAL_CSn_PIN) == 0xFF) 
     {
@@ -801,6 +804,14 @@
   cc1100_spi_output(cc1100, status);
 }
 
+#if defined(CC1101MM)
+int cc1100_update(int dev_num)
+{
+  struct _cc1100_t *cc1100 = (struct _cc1100_t *) machine.device[dev_num].data;
+  return cc1100_update_state (cc1100);
+}
+#endif
+
 /***************************************************/
 /***************************************************/
 /***************************************************/

Modified: devices/cc1100_2500/cc1100_2500_gdo.c
===================================================================
--- devices/cc1100_2500/cc1100_2500_gdo.c	2012-03-11 22:50:34 UTC (rev 825)
+++ devices/cc1100_2500/cc1100_2500_gdo.c	2012-03-12 14:05:34 UTC (rev 826)
@@ -16,10 +16,13 @@
  */
 
 /*
- * Implemented signals: 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x29, 0x2E, 0x3F
+ * Implemented signals: 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x1E (for cc1101mm), 0x29, 0x2E, 0x3F
  */
 
 #include "cc1100_2500_internals.h"
+#if defined(CC1101MM)
+#include "cc1101mm_dev.h"
+#endif
 
 
 /***************************************************/
@@ -116,6 +119,11 @@
 			}
 		}
 	}
+  
+#if defined(CC1101MM)
+  /* connection to cc1101mm */
+  cc1101mm_assert_gdo(event, assert);
+#endif
 }
 
 
@@ -209,9 +217,23 @@
 			cc1100_assert_gdo(cc1100, 0x07, CC1100_PIN_DEASSERT);
 #endif
 			break;
+#if defined(CC1101MM)
+    case 0x1E:
+      //always good RSSI level.
+      cc1100_assert_gdo(cc1100,0x1e,CC1100_PIN_ASSERT);
+      break;
 		case 0x29:
+      if(cc1100->fsm_state==CC1100_STATE_SLEEP) {
+        cc1100_assert_gdo(cc1100, 0x29, CC1100_PIN_ASSERT);
+      } else {
+        cc1100_assert_gdo(cc1100, 0x29, CC1100_PIN_DEASSERT);
+      }
+			break;
+#else
+      case 0x29:
 			cc1100_assert_gdo(cc1100, 0x29, CC1100_PIN_ASSERT);
 			break;
+#endif
 		case 0x3F:
 			cc1100_update_xosc(cc1100);
 			break;

Modified: devices/cc1100_2500/cc1100_2500_globals.h
===================================================================
--- devices/cc1100_2500/cc1100_2500_globals.h	2012-03-11 22:50:34 UTC (rev 825)
+++ devices/cc1100_2500/cc1100_2500_globals.h	2012-03-12 14:05:34 UTC (rev 826)
@@ -32,8 +32,13 @@
 #define CC1100_FS_WAKEUP_DELAY_US               45
 #define CC1100_SETTLING_DELAY_NS                44200
 #define CC1100_SETTLING_DELAY_US                44
+#if defined(CC1101MM)
+#define CC1100_CALIBRATE_DELAY_NS               0
+#define CC1100_CALIBRATE_DELAY_US               0
+#else
 #define CC1100_CALIBRATE_DELAY_NS               720600
 #define CC1100_CALIBRATE_DELAY_US               720
+#endif
 /* RC oscillator calibration time, cf AN047 p8 */
 #define CC1100_RC_CALIBRATE_DELAY_NS            2000000
 #define CC1100_RC_CALIBRATE_DELAY_US            2000

Modified: devices/cc1100_2500/cc1100_2500_internals.h
===================================================================
--- devices/cc1100_2500/cc1100_2500_internals.h	2012-03-11 22:50:34 UTC (rev 825)
+++ devices/cc1100_2500/cc1100_2500_internals.h	2012-03-12 14:05:34 UTC (rev 826)
@@ -185,6 +185,9 @@
 void	 cc1100_reset_internal          (struct _cc1100_t *cc1100);
 int	 cc1100_io_pins	                (struct _cc1100_t *cc1100);
 void	 cc1100_write_status		(struct _cc1100_t *cc1100);
+#if defined(CC1101MM)
+int   cc1100_update_state            (struct _cc1100_t *cc1100);
+#endif
 
 
 /***************************************

Modified: devices/cc1100_2500/cc1100_2500_registers.c
===================================================================
--- devices/cc1100_2500/cc1100_2500_registers.c	2012-03-11 22:50:34 UTC (rev 825)
+++ devices/cc1100_2500/cc1100_2500_registers.c	2012-03-12 14:05:34 UTC (rev 826)
@@ -129,7 +129,11 @@
       /* Need to calibrate if the frequency registers are modified */
       CC1100_UNCALIBRATE(cc1100);
     } 
-  else if ((addr <= CC1100_REG_IOCFG0) && (val != old_val)) 
+  #if defined(CC1101MM)
+  else if ((addr <= CC1100_REG_IOCFG0))
+  #else
+  else if ((addr <= CC1100_REG_IOCFG0) && (val != old_val))
+  #endif
     {
       /* Need to update pins if modified */
       cc1100_update_gdo(cc1100, val);

Modified: devices/cc1100_2500/cc1100_2500_state.c
===================================================================
--- devices/cc1100_2500/cc1100_2500_state.c	2012-03-11 22:50:34 UTC (rev 825)
+++ devices/cc1100_2500/cc1100_2500_state.c	2012-03-12 14:05:34 UTC (rev 826)
@@ -210,7 +210,7 @@
 /***************************************************/
 /***************************************************/
 int cc1100_update_state_fs_calibrate (struct _cc1100_t *cc1100) {
-	
+  
 	/* Check if calibration is over */
 	if (MACHINE_TIME_GET_NANO() >= cc1100->fsm_timer) {
 		CC1100_CALIBRATE(cc1100);
@@ -403,10 +403,14 @@
 /***************************************************/
 /***************************************************/
 
-int cc1100_update (int dev_num) 
+#if defined(CC1101MM)
+int cc1100_update_state (struct _cc1100_t *cc1100)
 {
+#else
+int cc1100_update (int dev_num)
+{
   struct _cc1100_t *cc1100 = (struct _cc1100_t *) machine.device[dev_num].data;
-
+#endif
     /* Update gdo */
   cc1100_update_xosc(cc1100);
 	

Added: devices/cc1100_2500/cc1101mm_dev.c
===================================================================
--- devices/cc1100_2500/cc1101mm_dev.c	                        (rev 0)
+++ devices/cc1100_2500/cc1101mm_dev.c	2012-03-12 14:05:34 UTC (rev 826)
@@ -0,0 +1,903 @@
+
+/**
+ *  \file   cc1101mm_dev.c
+ *  \brief  MSP430 CC1101 definition
+ *  \author Bernhard Dick
+ *  \date   2011
+ **/
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "arch/common/hardware.h"
+#include "devices/devices.h"
+#include "machine/machine.h"
+#include "liblogpkt/pcap.h"
+#include "arch/msp430/msp430.h"
+
+#include "cc1100_2500_internals.h"
+
+#include "cc1101mm_dev.h"
+
+#if defined(CC1101MM)
+/* ************************************************** */
+/* ************************************************** */
+/* ************************************************** */
+//used internal register function
+uint8_t cc1100_read_ro_register                 (struct _cc1100_t *cc1100, uint8_t addr);
+
+/* Global Variables (not backtracked) */
+int CC1100_XOSC_FREQ_MHz;
+int CC1100_XOSC_PERIOD_NS;
+int CC1100_RCOSC_FREQ_KHz;
+int CC1100_RCOSC_PERIOD_NS;
+
+tracer_id_t TRACER_CC1100_STATE;
+tracer_id_t TRACER_CC1100_STROBE;
+tracer_id_t TRACER_CC1100_CS;
+tracer_id_t TRACER_CC1100_SO;
+tracer_id_t TRACER_CC1100_GDO0;
+tracer_id_t TRACER_CC1100_GDO2;
+
+#define cc1101 MCU_RFCC1101
+#define cc1100 cc1101.cc1100
+
+/* forward prototypes */
+void cc1101mm_setstate         (int8_t state);
+void cc1101mm_data             (int8_t data);
+void cc1101mm_instruction      (uint8_t val);
+void cc1101mm_writestatus      (int rxfifo);
+void cc1101mm_writestatus_data (int rxfifo);
+
+void
+cc1101mm_create ()
+{
+  // Register memory range
+  msp430_io_register_range8 (CC1101_IOMEM_OFFSET, CC1101_IOMEM_END, cc1101mm_read8, cc1101mm_write8);
+  msp430_io_register_range16 (CC1101_IOMEM_OFFSET, CC1101_IOMEM_END, cc1101mm_read16, cc1101mm_write16);
+
+
+  // Create own CC1101 struct
+  //static struct _cc1100_t newcc1100;
+  //cc1100 = &newcc1100;
+  //
+  // cc1100 structure is statically allocated in the
+  // main msp430 stucture
+  cc1100 = & MCU_RFCC1101.cc1100_struct;
+
+  //TODO change this according to "no internal osc"
+  CC1100_XOSC_FREQ_MHz = 27;
+  CC1100_XOSC_PERIOD_NS = 1000 / 27;
+  CC1100_RCOSC_FREQ_KHz = 2700 / 750;
+  CC1100_RCOSC_PERIOD_NS = (750 * 1000) / 27;
+
+  cc1100->worldsens_radio_id = worldsens_c_rx_register ((void*) cc1100, cc1100_callback_rx, "omnidirectional");
+  cc1100->channel_busy_timer = 0;
+
+  TRACER_CC1100_STATE = tracer_event_add_id (8, "state", "cc1100");
+  TRACER_CC1100_STROBE = tracer_event_add_id (8, "strobe", "cc1100");
+  TRACER_CC1100_CS = tracer_event_add_id (1, "cs", "cc1100");
+  TRACER_CC1100_SO = tracer_event_add_id (1, "so", "cc1100");
+  TRACER_CC1100_GDO0 = tracer_event_add_id (1, "gdo0", "cc1100");
+  TRACER_CC1100_GDO2 = tracer_event_add_id (1, "gdo2", "cc1100");
+
+  /* init packets log */
+  logpkt_init_interface (cc1100->worldsens_radio_id, "cc1100", PCAP_DLT_USER0);
+  
+
+}
+
+/* ************************************************** */
+/* ************************************************** */
+
+/* ************************************************** */
+
+int
+cc1101mm_reset ()
+{
+  cc1100_reset_internal (cc1100);
+  cc1100->registers[CC1100_REG_VERSION] = 0x06; //version 0x06 instead of 0x03
+  cc1100->registers[CC1100_REG_IOCFG0] = 0x2E; //The default setting for IOCFG0.GDO0_CFGx changed from 0x3F (RFCLK/192) to 0x2E (3-state).
+
+
+  /* statemachine */
+  cc1101.statemachine.data = 0x00;
+  cc1101.statemachine.instruction = 0x00;
+  cc1101.statemachine.parameter = 0x00;
+  cc1101.statemachine.rxfifo = 0x00;
+  cc1101mm_setstate (CC1101MM_WAIT_INSTR);
+
+  /* registers */
+  cc1101.rf1aifctl0.s = 0x0000;
+  cc1101.rf1aifctl1.s = 0x0010;
+  cc1101.rf1aiferr.s = 0x0000;
+  cc1101.rf1aiferrv = 0x0000;
+  cc1101.rf1aifiv = 0x0000;
+  cc1101.rf1ainstrw = 0x0000;
+  cc1101.rf1ainstr1b = 0x00;
+  cc1101.rf1ainstr2b = 0x00;
+  cc1101.rf1adinw = 0x0000;
+  cc1101.rf1astatw = 0x0000;
+  cc1101.rf1astat1w = 0x0000;
+  cc1101.rf1astat2w = 0x0000;
+  cc1101.rf1adoutw = 0x0000;
+  cc1101.rf1adout1w = 0x0000;
+  cc1101.rf1adout2w = 0x0000;
+  cc1101.rf1ain = 0x0000;
+  cc1101.rf1aifg = 0x0000;
+  cc1101.rf1aies = 0x0000;
+  cc1101.rf1aie = 0x0000;
+  cc1101.rf1aiv = 0x0000;
+  
+  cc1101.last_GO0_pin = 0;
+  cc1101.last_GO1_pin = 0;
+  cc1101.last_GO2_pin = 0;
+  
+  cc1101.send_intr = 0;
+
+  return 0;
+}
+
+/* ************************************************** */
+/* ************************************************** */
+
+/* ************************************************** */
+
+void
+cc1101mm_update ()
+{
+  cc1100_update_state (cc1100);
+  
+  /* RF1AIFG */
+  /* high->low / low->high opposite to datasheet (expected by simpliciti) */
+  if(cc1100->GO0_pin != cc1101.last_GO0_pin) {
+    if(((cc1100->GO0_pin) && ((cc1101.rf1aie & 0x01)==0x01)) || ((!cc1100->GO0_pin) && ((cc1101.rf1aie & 0x01)==0x00))) {
+      cc1101.rf1aifg |= 0x01;
+    }
+  }
+  
+  if(cc1100->GO1_pin != cc1101.last_GO1_pin) {
+    if((!cc1100->GO1_pin && ((cc1101.rf1aie & 0x02)==0x00)) || (cc1100->GO1_pin && ((cc1101.rf1aie & 0x02)==0x02))) {
+      cc1101.rf1aifg |= 0x02;
+    }
+  }
+  if(cc1100->GO2_pin != cc1101.last_GO2_pin) {
+    if((!cc1100->GO2_pin && ((cc1101.rf1aie & 0x04)==0x00)) || (cc1100->GO2_pin && ((cc1101.rf1aie & 0x04)==0x04))) {
+      cc1101.rf1aifg |= 0x04;
+    }
+  }
+  
+  cc1101.last_GO0_pin = cc1100->GO0_pin;
+  cc1101.last_GO1_pin = cc1100->GO1_pin;
+  cc1101.last_GO2_pin = cc1100->GO2_pin;
+}
+
+/* ************************************************** */
+/* ************************************************** */
+
+/* ************************************************** */
+
+int8_t
+cc1101mm_read8 (uint16_t addr)
+{
+  HW_DMSG ("msp430:cc1101:  byte read at address 0x%04x\n", addr);
+  int8_t res;
+  switch (addr)
+    {
+    case RF1AIFCTL1:
+      res = cc1101.rf1aifctl1.s >> 8;
+      break;
+    case RF1AIFCTL1 + 1:
+      res = cc1101.rf1aifctl1.s;
+      break;
+    case RF1ASTATW:
+      res = cc1101.rf1astatw;
+      break;
+    case RF1ASTATW + 1:
+      res = (cc1101.rf1astatw >> 8);
+      break;
+    case RF1ASTAT1W:
+      res = cc1101.rf1astat1w;
+      break;
+    case RF1ASTAT1W + 1:
+      res = (cc1101.rf1astat1w >> 8);
+      break;
+    case RF1ASTAT2W + 1:
+      res = (cc1101.rf1astat2w >> 8);
+      break;
+    default:
+      ERROR ("msp430:cc1101: bad byte read at address 0x%04x\n", addr);
+      res = 0;
+    }
+  HW_DMSG ("msp430:cc1101:  value 0x%02x\n", res & 0xff);
+  return res;
+}
+
+/* ************************************************** */
+/* ************************************************** */
+
+/* ************************************************** */
+
+int16_t
+cc1101mm_read16 (uint16_t addr)
+{
+  HW_DMSG ("msp430:cc1101:  word read at address 0x%04x\n", addr);
+  int16_t res;
+  switch (addr)
+    {
+    case RF1AIFCTL0:
+      res = cc1101.rf1aifctl0.s;
+      break;
+    case RF1AIFCTL1:
+      res = cc1101.rf1aifctl1.s;
+      break;
+    case RF1AIFERR:
+      res = cc1101.rf1aiferr.s;
+      break;
+    case RF1AIFERRV:
+      res = cc1101.rf1aiferrv;
+      break;
+    case RF1AIFIV:
+      res = cc1101.rf1aifiv;
+      break;
+    case RF1AINSTRW:
+      res = cc1101.rf1ainstrw;
+      break;
+    case RF1AINSTR1W:
+      res = 0x00 + cc1101.rf1ainstr1b;
+      break;
+    case RF1AINSTR2W:
+      res = 0x00 + cc1101.rf1ainstr2b;
+      break;
+    case RF1ADINW:
+      res = cc1101.rf1adinw;
+      break;
+    case RF1ASTATW:
+      res = cc1101.rf1astatw;
+      break;
+    case RF1ASTAT1W:
+      res = cc1101.rf1astat1w;
+      break;
+    case RF1ASTAT2W:
+      res = cc1101.rf1astat2w;
+      break;
+    case RF1ADOUTW:
+      res = cc1101.rf1adoutw;
+      cc1101.rf1aifctl1.b.rfdoutifg = 0;
+      break;
+    case RF1ADOUT1W:
+      res = cc1101.rf1adout1w;
+      cc1101.rf1aifctl1.b.rfdoutifg = 0;
+      break;
+    case RF1ADOUT2W:
+      res = cc1101.rf1adout2w;
+      cc1101.rf1aifctl1.b.rfdoutifg = 0;
+      break;
+    case RF1AIN:
+      res = cc1101.rf1ain;
+      if (cc1100->GO0_pin)
+        {
+          res |= 1;
+        }
+      if (cc1100->GO1_pin)
+        {
+          res |= (1 << 1);
+        }
+      if (cc1100->GO2_pin)
+        {
+          res |= (1 << 2);
+        }
+      if (cc1100->rxOverflow)
+        {
+          res |= (1 << 3);
+          res |= (1 << 4);
+        }
+      HW_DMSG ("msp430:cc1101: word read RF1AIN 0x%04x = 0x%04x\n", addr, res & 0xffff);
+      break;
+    case RF1AIFG:
+      res = cc1101.rf1aifg;
+      HW_DMSG ("msp430:cc1101: word read RF1AIFG = 0x%04x\n", res & 0xffff);
+      break;
+    case RF1AIES:
+      res = cc1101.rf1aies;
+      break;
+    case RF1AIE:
+      res = cc1101.rf1aie;
+      break;
+    case RF1AIV:
+      res = cc1101.rf1aiv;
+      break;
+    default:
+      ERROR ("msp430:cc1101: bad word read at address 0x%04x\n", addr);
+      res = 0;
+    }
+  return res;
+}
+
+/* ************************************************** */
+/* ************************************************** */
+
+/* ************************************************** */
+
+void
+cc1101mm_write8 (uint16_t addr, int8_t val)
+{
+  HW_DMSG ("msp430:cc1101: byte write at address 0x%04x = 0x%02x\n", addr, val & 0xff);
+  switch (addr)
+    {
+    case RF1AINSTRW: /* RF1ADINB */
+      cc1101.rf1ainstrw = (cc1101.rf1ainstrw & 0x00ff) | val;
+      cc1101mm_data (val);
+      break;
+    case RF1AINSTRW + 1: /* RF1AINSTRB */
+      cc1101.rf1ainstrw = (cc1101.rf1ainstrw & 0xff00) | val;
+      cc1101mm_instruction (val);
+      break;
+    case RF1AINSTR1W + 1: /* RF1AINSTR1B */
+      cc1101.rf1ainstr1b = val;
+      cc1101mm_instruction (val);
+      cc1101mm_data (0x00);
+      break;
+    default:
+      ERROR ("msp430:cc1101: bad byte write at address 0x%04x = 0x%02x\n", addr, val & 0xff);
+    }
+}
+
+/* ************************************************** */
+/* ************************************************** */
+
+/* ************************************************** */
+
+void
+cc1101mm_write16 (uint16_t addr, int16_t val)
+{
+  uint16_t UNUSED tmp = val;
+  HW_DMSG ("msp430:cc1101: word write at address 0x%04x = 0x%04x\n", addr, val & 0xffff);
+  switch (addr)
+    {
+    case RF1AIFCTL1:
+      cc1101.rf1aifctl1.s = val;
+      break;
+    case RF1AINSTRW:
+      cc1101.rf1ainstrw = val;
+      cc1101mm_instruction (val >> 8); //little endian way!
+      cc1101mm_data (val);
+      break;
+    case RF1AIFG:
+      cc1101.rf1aifg = val;
+    case RF1AIES:
+      HW_DMSG ("msp430:cc1101: word write at RF1AIES = 0x%04x\n", val & 0xffff);
+      cc1101.rf1aies = val;
+      break;
+    case RF1AIE:
+      HW_DMSG ("msp430:cc1101: word write at RF1AIE = 0x%04x\n", val & 0xffff);
+      cc1101.rf1aie = val;
+      break;
+    default:



More information about the Wsim-commits mailing list