view src/cs/drivers/drv_app/buzzer/buzzer.c @ 636:57e67ca2e1cb

pcmdata.c: default +CGMI to "FreeCalypso" and +CGMM to model The present change has no effect whatsoever on Falconia-made and Openmoko-made devices on which /pcm/CGMI and /pcm/CGMM files have been programmed in FFS with sensible ID strings by the respective factories, but what should AT+CGMI and AT+CGMM queries return when the device is a Huawei GTM900 or Tango modem that has been converted to FreeCalypso with a firmware change? Before the present change they would return compiled-in defaults of "<manufacturer>" and "<model>", respectively; with the present change the firmware will self-identify as "FreeCalypso GTM900-FC" or "FreeCalypso Tango" on the two respective targets. This firmware identification will become important if someone incorporates an FC-converted GTM900 or Tango modem into a ZeroPhone-style smartphone where some high-level software like ofono will be talking to the modem and will need to properly identify this modem as FreeCalypso, as opposed to some other AT command modem flavor with different quirks. In technical terms, the compiled-in default for the AT+CGMI query (which will always be overridden by the /pcm/CGMI file in FFS if one is present) is now "FreeCalypso" in all configs on all targets; the compiled-in default for the AT+CGMM query (likewise always overridden by /pcm/CGMM if present) is "GTM900-FC" if CONFIG_TARGET_GTM900 or "Tango" if CONFIG_TARGET_TANGO or the original default of "<model>" otherwise.
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 19 Jan 2020 20:14:58 +0000
parents 945cf7f506b2
children
line wrap: on
line source

/*
 * BUZZER.C
 *
 * Buzzer driver
 *
 * Target : ARM
 *
 * Copyright (c) Texas Instruments 2000
 *
 */


#include "main/sys_types.h"
#include "memif/mem.h"
#include "armio/armio.h"
#include "buzzer.h"
#include "timer/timer.h"

#include "board.cfg"

/* 
 * Initialize buzzer
 *
 */
void BZ_Init(void)
{
}

/*
 * BZ_Enable / BZ_Disable
 * 
 * Enable / disable buzzer
 * 
 * The buzzer uses timer 1
 */ 
void BZ_Enable(void)
{
  *((volatile SYS_UWORD16 *) ARMIO_PWM_CNTL) |= BZ_ON; 
}

void BZ_Disable(void)
{
  *((volatile SYS_UWORD16 *) ARMIO_PWM_CNTL) &= ~BZ_ON; 
}

/*
 * BZ_Tone
 * 
 * Changes the timer count to set the tone frequency in Hz
 * 
 * 58 ticks= 1 ms, which give a frequency of 500 Hz
 *
 *
 */
void BZ_Tone(int f)
{
    if (f > 255)
    {
        f = 255;
    }
  *((volatile SYS_UWORD16 *) ARMIO_LOAD_TIM) = f;
}

/*
 * BZ_Volume
 * 
 * Changes the buzzer volume
 * 
 */
void BZ_Volume(int v)
{
  // the level range is 0 up to 63
    if (v > 63)
    {
        v = 63;
    }
  *((volatile SYS_UWORD16 *) BZ_LEVEL) = v;
}

/*
 * BZ_KeyBeep_ON
 * 
 * Audio feedback to user after keybeep
 *
 */
void BZ_KeyBeep_ON(void)
{
  volatile int i;

  BZ_Init ();
  BZ_Volume (255);
  BZ_Enable ();
  BZ_Tone (50);
  
  for (i = 0; i < 17000; i++)
    ;
  
  BZ_Disable ();
}



/*
 * BZ_KeyBeep_OFF
 * 
 * Audio feedback to user after keybeep
 *
 */
void BZ_KeyBeep_OFF(void)
{
  volatile int i;

  BZ_Init ();
  BZ_Volume (255);
  BZ_Enable ();
  BZ_Tone (100);
  
  for (i = 0; i < 17000; i++)
    ;
  
  BZ_Disable ();
}



/*
 * LT_Enable / LT_Disable
 * 
 * Enable / disable LCD lighting
 * 
 */
void LT_Enable(void)
{
#if (BOARD == 7 || BOARD == 8 || BOARD == 9)
   *((volatile SYS_UWORD16 *) ARMIO_PWM_CNTL) |= LT_ON;
#endif
}
void LT_Disable(void)
{
#if (BOARD == 7 || BOARD == 8 || BOARD == 9)
   *((volatile SYS_UWORD16 *) ARMIO_PWM_CNTL) &= ~LT_ON;
#endif
}


/*
 * LT_Level
 * 
 * Set LCD display level
 */
void LT_Level(SYS_WORD8 level)
{
   if (level > 63) level=63;

   // the level range is 0 up to 63
   *((volatile SYS_UWORD16 *) LT_LEVEL) = level;
}


/*
 * LT_Status
 * 
 * Return lighting status for sleep manager
 * 
 */
SYS_BOOL LT_Status(void)
{
#if (BOARD == 7 || BOARD == 8 || BOARD == 9)
   if (*((volatile SYS_UWORD16 *) ARMIO_PWM_CNTL) & LT_ON) 
      return(1);		 // the light is on
   else
      return(0); 
#endif

return(0); 

}