@@ -1,38 +1,16 @@
/*
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include " ch.h"
#include " hal.h"
#include " phi_lib/phi_lib.h"
#include " phi_lib/phi_bl_common.h"
#include " usbcfg.h"
#include " lcd.h"
#include " narvi_midi.h"
static uint8_t ii;
#define LINE_RS PAL_LINE (GPIOE, 14U ) // MOSI
#define LINE_RW PAL_LINE (GPIOE, 13U ) // MISO
#define LINE_E PAL_LINE (GPIOE, 12U ) // CLK
#define LINE_A PAL_LINE (GPIOE, 11U ) // D4 unused
/* ===========================================================================*/
/* LCD configuration */
/* ===========================================================================*/
/* Data PIN are connected from PC0 to PC7 */
#define LINE_RS PAL_LINE (GPIOE, 13U ) // MISO
#define LINE_E PAL_LINE (GPIOE, 14U ) // MOSI
#define LINE_A PAL_LINE (GPIOE, 14U ) // UNUSED
#if !LCD_USE_4_BIT_MODE
#error sux
#endif
@@ -41,38 +19,11 @@ static uint8_t ii;
#define LINE_D6 PAL_LINE (GPIOE, 9U )
#define LINE_D7 PAL_LINE (GPIOE, 10U )
/* ===========================================================================*/
/* LCD configuration */
/* ===========================================================================*/
#if LCD_USE_DIMMABLE_BACKLIGHT
static const PWMConfig pwmcfg = {
100000 , /* 100kHz PWM clock frequency. */
100 , /* PWM period is 1000 cycles. */
NULL ,
{
{PWM_OUTPUT_ACTIVE_HIGH, NULL },
{PWM_OUTPUT_DISABLED, NULL },
{PWM_OUTPUT_DISABLED, NULL },
{PWM_OUTPUT_DISABLED, NULL }
},
0 ,
0
};
#endif
static const lcd_pins_t lcdpins = {
LINE_RS,
LINE_RW,
LINE_E,
LINE_A,
{
#if !LCD_USE_4_BIT_MODE
LINE_D0,
LINE_D1,
LINE_D2,
LINE_D3,
#endif
LINE_D4,
LINE_D5,
LINE_D6,
@@ -86,11 +37,6 @@ static const LCDConfig lcdcfg = {
LCD_SET_FONT_5X10, /* Font 5x10 */
LCD_SET_2LINES, /* 2 lines */
&lcdpins, /* pin map */
#if LCD_USE_DIMMABLE_BACKLIGHT
&PWMD1, /* PWM Driver for back-light */
&pwmcfg, /* PWM driver configuration for back-light */
0 , /* PWM channel */
#endif
100 , /* Back-light */
};
@@ -116,8 +62,6 @@ static THD_FUNCTION(Thread2, arg) {
/* Initialization and main thread. */
/* ===========================================================================*/
extern audio_state_t audio;
char boot_user_status[16 ];
@@ -209,81 +153,41 @@ int main(void) {
halInit ();
force_bl = FALSE ; // TODO
if (!force_bl) {
if (!force_bl) {
boot_user ();
} else {
strcpy (boot_user_status, " Forced" );
}
chSysInit ();
lcdInit ();
palSetLineMode (LINE_RS, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
palSetLineMode (LINE_E, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
lcdStart (&LCDD1, &lcdcfg);
lcdWriteString (&LCDD1, " PHI Narvi - BL" , 0 );
lcdWriteString (&LCDD1, boot_user_status, 40 );
lcdInit ();
#if LCD_USE_DIMMABLE_BACKLIGHT
/* Configuring Anode PIN as TIM1 CH1 alternate function. */
palSetLineMode (LINE_A, PAL_MODE_ALTERNATE (1 ));
#else
/* Configuring Anode PIN as TIM1 CH1 alternate function. */
palSetLineMode (LINE_A, PAL_MODE_OUTPUT_PUSHPULL |
PAL_STM32_OSPEED_HIGHEST);
#endif
/* Configuring RW, RS and E PIN as Output Push Pull. Note that Data PIN are
managed Internally */
palSetLineMode (LINE_RW, PAL_MODE_OUTPUT_PUSHPULL |
PAL_STM32_OSPEED_HIGHEST);
palSetLineMode (LINE_RS, PAL_MODE_OUTPUT_PUSHPULL |
PAL_STM32_OSPEED_HIGHEST);
palSetLineMode (LINE_E, PAL_MODE_OUTPUT_PUSHPULL |
PAL_STM32_OSPEED_HIGHEST);
lcdStart (&LCDD1, &lcdcfg);
lcdWriteString (&LCDD1, " NARVI BL" , 0 );
lcdWriteString (&LCDD1, boot_user_status, 40 );
// ab_main_midi_init();
mduObjectInit (&MDU1);
mduStart (&MDU1, &midiusbcfg);
// ab_main_midi_init();
mduObjectInit (&MDU1);
mduStart (&MDU1, &midiusbcfg);
audioObjectInit (&audio );
narvi_midi_init ( );
/*
* Activates the USB driver and then the USB bus pull-up on D+.
* Note, a delay is inserted in order to not have to disconnect the cable
* after a reset.
*/
usbDisconnectBus (midiusbcfg.usbp );
chThdSleepMilliseconds (1000 );
usbStart (midiusbcfg.usbp , &usbcfg);
usbConnectBus (midiusbcfg.usbp );
chThdCreateStatic (waThread2, sizeof (waThread2), NORMALPRIO + 10 , Thread2, NULL );
/*
* Activates the USB driver and then the USB bus pull-up on D+.
* Note, a delay is inserted in order to not have to disconnect the cable
* after a reset.
*/
usbDisconnectBus (midiusbcfg.usbp );
chThdSleepMilliseconds (1000 );
usbStart (midiusbcfg.usbp , &usbcfg);
usbConnectBus (midiusbcfg.usbp );
/*
* Creating the blinker threads.
*/
// codec_init();
chThdCreateStatic (waThread2, sizeof (waThread2),
NORMALPRIO + 10 , Thread2, NULL );
// while (1) chThdSleepMilliseconds(10);
/*
* Normal main() thread activity, in this demo it just performs
* a shell respawn upon its termination.
*/
while (true ) {
chThdSleepMilliseconds (500 );
}
while (true ) {
chThdSleepMilliseconds (500 );
}
}