コード例 #1
0
ファイル: main.c プロジェクト: Alucard3571/MetaWatch-WDS11x
void main(void)
{
  /* Turn off the watchdog timer */
  WDTCTL = WDTPW + WDTHOLD;

  /* clear reason for reset */
  SYSRSTIV = 0;
  
  /* disable DMA during read-modify-write cycles */
  DMACTL4 = DMARMWDIS;
  
  unsigned char MspVersion = GetMsp430HardwareRevision();
    
  InitializeCalibrationData();
  
  ConfigureHardware();

  OsalNvInit(0);
  
  InitializeDebugFlags();      
  InitializeButtons();
  InitializeVibration();
  InitializeOneSecondTimers();
  
  InitializeBufferPool();    

  InitializeSppTask();
  
  InitializeRealTimeClock();       

  InitializeBackgroundTask();   

  InitializeDisplayTask();   

  InitializeAdc();
  
#if 0
  /* timeout is 16 seconds */
  hal_SetWatchdogTimeout(16); 
#endif

#ifdef CHECK_FOR_PMM15
  /* make sure error pmm15 does not exist */
  while ( PMM15Check() );
#endif
  
  /* Errata PMM17 - automatic prolongation mechanism 
   * SVSLOW is disabled
   */
  *(unsigned int*)(0x0110) = 0x9602;
  *(unsigned int*)(0x0112) |= 0x0800;
  
  PrintString("Starting Task Scheduler\r\n");
  vTaskStartScheduler();

  /* if vTaskStartScheduler exits an error occured. */
  PrintString("Program Error\r\n");
  ForceWatchdogReset();
  
}
コード例 #2
0
ファイル: main.c プロジェクト: seanhayward/MetaWatch-Gen2
void main(void)
{
    ENABLE_LCD_LED();

#if ENABLE_WATCHDOG
    RestartWatchdog();
#else
    WDTCTL = WDTPW + WDTHOLD;
#endif

    /* clear shipping mode, if set to allow configuration */
    PMMCTL0_H = PMMPW_H;
    PM5CTL0 &= ~LOCKLPM5;

    /* disable DMA during read-modify-write cycles */
    DMACTL4 = DMARMWDIS;

    DetermineErrata();

#ifdef BOOTLOADER

    /*
     * enable RAM alternate interrupt vectors
     * these are defined in AltVect.s43 and copied to RAM by cstartup
     */
    SYSCTL |= SYSRIVECT;

    ClearBootloaderSignature();

#endif

    /* calibration data is used for clock setup */
    InitializeCalibrationData();

#ifndef BOOTLOADER
    SaveResetSource();
#endif

    SetupClockAndPowerManagementModule();

    OsalNvInit(0);

    /* change the mux settings according to presense of the charging clip */
    InitializeMuxMode();
    ChangeMuxMode();

    InitDebugUart();
    TestModeControl();

    /* adc is required to get the board configuration */
    InitializeAdc();
    ConfigureDefaultIO(GetBoardConfiguration());

    InitializeDebugFlags();

//  InitButton();

    InitializeVibration();
    InitializeOneSecondTimers();

    InitializeBufferPool();
    InitializeWrapperTask();
    InitializeRealTimeClock();

    InitializeDisplayTask();

    DISABLE_LCD_LED();

#if CHECK_FOR_PMM15
    /* make sure error pmm15 does not exist */
    while ( PMM15Check() );
#endif

    /* Errata PMM17 - automatic prolongation mechanism
     * SVSLOW is disabled
     */
    *(unsigned int*)(0x0110) = 0x9602;
    *(unsigned int*)(0x0112) |= 0x0800;

    WhoAmI();
    PrintResetSource();

    /* if a watchdog occurred then print and save information about the source */
    WatchdogTimeoutHandler(GetResetSource());

    PrintString("Starting Task Scheduler\r\n");
    SetUartNormalMode();

    vTaskStartScheduler();

    /* if vTaskStartScheduler exits an error occured. */
    PrintString("Program Error\r\n");
    ForceWatchdogReset();
}
コード例 #3
0
ファイル: main.c プロジェクト: rbrowngt/MetaWatch-WDS11x-IAR
void main(void)
{
  /* Turn off the watchdog timer */
  WDTCTL = WDTPW + WDTHOLD;

  /* clear reason for reset */
  SYSRSTIV = 0;
  
  /* disable DMA during read-modify-write cycles */
  DMACTL4 = DMARMWDIS;
  
  InitializeCalibrationData();
  
  ConfigureHardware();

  osal_nv_init(0);
  
  InitializeDebugFlags();
  
  InitializeBufferPool();    

  InitializeSppTask();
  
  InitializeCommandTask();
  
  InitializeRealTimeClock();       

  InitializeBackgroundTask();   

  InitializeDisplayTask();   

  InitializeAdc();

#ifdef DIGITAL

  InitializeSerialRamTask();
  
  InitializeLcdTask();

#else
  
  unsigned char QueueOfZeroLength = 0;
  QueueHandles[SRAM_QINDEX] = 
    xQueueCreate( QueueOfZeroLength, MESSAGE_QUEUE_ITEM_SIZE );
  
  QueueHandles[LCD_TASK_QINDEX] = 
    xQueueCreate( QueueOfZeroLength, MESSAGE_QUEUE_ITEM_SIZE );
  
#endif
  
#if 0
  InitializePedometerTask();
#endif
  
#if 0
  /* timeout is 16 seconds */
  hal_SetWatchdogTimeout(16); 
#endif

  extern xSemaphoreHandle CrcMutex;
  CrcMutex = xSemaphoreCreateMutex();
  xSemaphoreGive(CrcMutex);

#if 0
  SetSniffSlotParameter(MaxInterval, 8);
  SetSniffSlotParameter(MinInterval, 6);
  SetSniffModeEntryDelay(200);
#endif
  
  
  /* Start the Task Scheduler. */
  vTaskStartScheduler();

  /* if vTaskStartScheduler exits an error occured. */
  PrintString("Program Error\r\n");

}
コード例 #4
0
/* The value in RAM must be updated if the phone writes the value in
 * flash (until the code is changed to read the value from flash)
 */
static void NvUpdater(unsigned int NvId)
{
  switch (NvId)
  {
#ifdef DIGITAL
    case NVID_IDLE_BUFFER_CONFIGURATION:
      InitializeIdleBufferConfig();
      break;
    case NVID_IDLE_BUFFER_INVERT:
      InitializeIdleBufferInvert();
      break;
#endif

    case NVID_IDLE_MODE_TIMEOUT:
    case NVID_APPLICATION_MODE_TIMEOUT:
    case NVID_NOTIFICATION_MODE_TIMEOUT:
    case NVID_RESERVED_MODE_TIMEOUT:
      InitializeModeTimeouts();
      break;

#ifdef ANALOG
    case NVID_IDLE_DISPLAY_TIMEOUT:
    case NVID_APPLICATION_DISPLAY_TIMEOUT:
    case NVID_NOTIFICATION_DISPLAY_TIMEOUT:
    case NVID_RESERVED_DISPLAY_TIMEOUT:
      InitializeDisplayTimeouts();
      break;
#endif

    case NVID_SNIFF_DEBUG:
    case NVID_BATTERY_DEBUG:
    case NVID_CONNECTION_DEBUG:
      InitializeDebugFlags();
      break;

    case NVID_RSTNMI_CONFIGURATION:
      InitializeRstNmiConfiguration();
      break;

    case NVID_MASTER_RESET:
      /* this gets handled on reset */
      break;

    case NVID_LOW_BATTERY_WARNING_LEVEL:
    case NVID_LOW_BATTERY_BTOFF_LEVEL:
      InitializeLowBatteryLevels();
      break;

    case NVID_BATTERY_SENSE_INTERVAL:
      InitializeBatteryMonitorInterval();
      break;

    case NVID_LIGHT_SENSE_INTERVAL:
      break;

    case NVID_SECURE_SIMPLE_PAIRING_ENABLE:
      /* not for phone control - reset watch */
      break;

    case NVID_LINK_ALARM_ENABLE:
      InitializeLinkAlarmEnable();
      break;

    case NVID_LINK_ALARM_DURATION:
      break;

    case NVID_PAIRING_MODE_DURATION:
      /* not for phone control - reset watch */
      break;

    case NVID_TIME_FORMAT:
      InitializeTimeFormat();
      break;

    case NVID_DATE_FORMAT:
      InitializeDateFormat();
      break;

#ifdef DIGITAL
    case NVID_DISPLAY_SECONDS:
      InitializeDisplaySeconds();
      break;
#endif

#ifdef ANALOG
    case NVID_TOP_OLED_CONTRAST_DAY:
    case NVID_BOTTOM_OLED_CONTRAST_DAY:
    case NVID_TOP_OLED_CONTRAST_NIGHT:
    case NVID_BOTTOM_OLED_CONTRAST_NIGHT:
      InitializeContrastValues();
      break;
#endif

  }
}