FS#12524 - iPod Classic/6G: hardware click support
Based on the piezo driver for the nano2g. Signed-off-by: Nils Wallménius <nils@rockbox.org>
This commit is contained in:
parent
6162d813e7
commit
e29619b4d2
|
@ -1458,6 +1458,7 @@ target/arm/s5l8702/debug-s5l8702.c
|
|||
target/arm/s5l8702/pcm-s5l8702.c
|
||||
target/arm/s5l8702/ipod6g/audio-ipod6g.c
|
||||
target/arm/s5l8702/ipod6g/adc-ipod6g.c
|
||||
target/arm/s5l8702/ipod6g/piezo-ipod6g.c
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
@ -204,6 +204,8 @@
|
|||
/* and doesn't handle them in the drive firmware */
|
||||
//#define MAX_PHYS_SECTOR_SIZE 4096
|
||||
|
||||
#define HAVE_HARDWARE_CLICK
|
||||
|
||||
/* Define this if you have adjustable CPU frequency */
|
||||
//#define HAVE_ADJUSTABLE_CPU_FREQ
|
||||
|
||||
|
|
95
firmware/target/arm/s5l8702/ipod6g/piezo-ipod6g.c
Normal file
95
firmware/target/arm/s5l8702/ipod6g/piezo-ipod6g.c
Normal file
|
@ -0,0 +1,95 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2006-2007 Robert Keevil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "system.h"
|
||||
#include "kernel.h"
|
||||
#include "piezo.h"
|
||||
|
||||
static unsigned int duration;
|
||||
static bool beeping;
|
||||
|
||||
void INT_TIMERA(void)
|
||||
{
|
||||
/* clear interrupt */
|
||||
TACON = TACON;
|
||||
if (!(--duration))
|
||||
{
|
||||
beeping = 0;
|
||||
TACMD = (1 << 1); /* TA_CLR */
|
||||
}
|
||||
}
|
||||
|
||||
static void piezo_start(unsigned short cycles, unsigned short periods)
|
||||
{
|
||||
#ifndef SIMULATOR
|
||||
duration = periods;
|
||||
beeping = 1;
|
||||
/* configure timer for 100 kHz */
|
||||
TACMD = (1 << 1); /* TA_CLR */
|
||||
TAPRE = 30 - 1; /* prescaler */ /* 12 MHz / 4 / 30 = 100 kHz */
|
||||
TACON = (1 << 13) | /* TA_INT1_EN */
|
||||
(0 << 12) | /* TA_INT0_EN */
|
||||
(0 << 11) | /* TA_START */
|
||||
(1 << 8) | /* TA_CS = PCLK / 4 */
|
||||
(1 << 6) | /* UNKNOWN bit */ /* external 12 MHz clock ??? */
|
||||
(1 << 4); /* TA_MODE_SEL = PWM mode */
|
||||
TADATA0 = cycles; /* set interval period */
|
||||
TADATA1 = cycles << 1; /* set interval period */
|
||||
TACMD = (1 << 0); /* TA_EN */
|
||||
#endif
|
||||
}
|
||||
|
||||
void piezo_stop(void)
|
||||
{
|
||||
#ifndef SIMULATOR
|
||||
TACMD = (1 << 1); /* TA_CLR */
|
||||
#endif
|
||||
}
|
||||
|
||||
void piezo_clear(void)
|
||||
{
|
||||
piezo_stop();
|
||||
}
|
||||
|
||||
bool piezo_busy(void)
|
||||
{
|
||||
return beeping;
|
||||
}
|
||||
|
||||
void piezo_init(void)
|
||||
{
|
||||
beeping = 0;
|
||||
}
|
||||
|
||||
void piezo_button_beep(bool beep, bool force)
|
||||
{
|
||||
if (force)
|
||||
while (beeping)
|
||||
yield();
|
||||
|
||||
if (!beeping)
|
||||
{
|
||||
if (beep)
|
||||
piezo_start(22, 457);
|
||||
else
|
||||
piezo_start(40, 4);
|
||||
}
|
||||
}
|
26
firmware/target/arm/s5l8702/ipod6g/piezo.h
Normal file
26
firmware/target/arm/s5l8702/ipod6g/piezo.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2006-2007 Robert Keevil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void piezo_init(void);
|
||||
void piezo_stop(void);
|
||||
void piezo_clear(void);
|
||||
bool piezo_busy(void);
|
||||
void piezo_button_beep(bool beep, bool force);
|
Loading…
Reference in New Issue
Block a user