bsp_audio.c
94 lines
| 2.5 KiB
| text/x-c
|
CLexer
r74 | /*------------------------------------------------------------------------------ | |||
-- This file is a part of the libuc, microcontroler library | ||||
-- Copyright (C) 2013, Alexis Jeandet | ||||
-- | ||||
-- 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 3 of the License, or | ||||
-- (at your option) any later version. | ||||
-- | ||||
-- This program is distributed in the hope that it will be useful, | ||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
-- GNU General Public License for more details. | ||||
-- | ||||
-- You should have received a copy of the GNU General Public License | ||||
-- along with this program; if not, write to the Free Software | ||||
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||||
------------------------------------------------------------------------------- | ||||
-- Author : Alexis Jeandet | ||||
-- Mail : alexis.jeandet@member.fsf.org | ||||
-------------------------------------------------------------------------------*/ | ||||
#include "bsp.h" | ||||
#include <streamdevices.h> | ||||
#include <malloc.h> | ||||
#include <gpio.h> | ||||
#include <uart.h> | ||||
#include <stdio.h> | ||||
#include <stm32f4xx_gpio.h> | ||||
#include <stm32f4xx_fsmc.h> | ||||
#include <i2c.h> | ||||
#include <core.h> | ||||
#include <terminal.h> | ||||
void bsp_Audio_init() | ||||
{ | ||||
vs10XXopen(&audioCodec0,VS1053SPI,vs1052setXCS,vs1052setRST,vs1052setXDCS,vs10XXDREQ); | ||||
if(audioCodec0.VERSION!=UNKNOWN) | ||||
{ | ||||
printf("detected Audio codec "); | ||||
switch (audioCodec0.VERSION) { | ||||
case VS1001: | ||||
printf("VS1001\n"); | ||||
break; | ||||
case VS1011: | ||||
printf("VS1011\n"); | ||||
break; | ||||
case VS1002: | ||||
printf("VS1002\n"); | ||||
break; | ||||
case VS1003: | ||||
printf("VS1003\n"); | ||||
break; | ||||
case VS1053: | ||||
printf("VS1053\n"); | ||||
break; | ||||
case VS1033: | ||||
printf("VS1033\n"); | ||||
break; | ||||
case VS1103: | ||||
printf("VS1103\n"); | ||||
break; | ||||
default: | ||||
printf("Unknown device\n"); | ||||
break; | ||||
} | ||||
} | ||||
} | ||||
void vs1052setXCS(char val) | ||||
{ | ||||
gpiosetval(VS1053xCS,(int)val); | ||||
} | ||||
void vs1052setXDCS(char val) | ||||
{ | ||||
//gpiosetval(LED1,(int)val); | ||||
gpiosetval(VS1053xDCS,(int)val); | ||||
} | ||||
void vs1052setRST(char val) | ||||
{ | ||||
if(val) | ||||
gpioset(VS1053xRESET); | ||||
else | ||||
gpioclr(VS1053xRESET); | ||||
} | ||||
int vs10XXDREQ() | ||||
{ | ||||
return gpiogetval(VS1053DREQ); | ||||
} | ||||