Subversion Repositories svn.mios32

Compare Revisions

Ignore whitespace Rev 1301 → Rev 1302

/trunk/apps/examples/blm_cheapo/app.c
New file
0,0 → 1,144
// $Id$
/*
* MIOS32 Application Template
*
* ==========================================================================
*
* Copyright (C) <year> <your name> (<your email address>)
* Licensed for personal non-commercial use only.
* All other rights reserved.
*
* ==========================================================================
*/
 
/////////////////////////////////////////////////////////////////////////////
// Include files
/////////////////////////////////////////////////////////////////////////////
 
#include <mios32.h>
#include <blm_cheapo.h>
 
#include "app.h"
 
// include everything FreeRTOS related we don't understand yet ;)
#include <FreeRTOS.h>
#include <portmacro.h>
#include <task.h>
#include <queue.h>
#include <semphr.h>
 
 
// define priority level for button handler (same as MIOS tasks)
#define PRIORITY_TASK_PERIOD_1mS ( tskIDLE_PRIORITY + 3 )
 
// local prototype of the task function
static void TASK_Period_1mS(void *pvParameters);
 
 
/////////////////////////////////////////////////////////////////////////////
// This hook is called after startup to initialize the application
/////////////////////////////////////////////////////////////////////////////
void APP_Init(void)
{
// initialize all LEDs
MIOS32_BOARD_LED_Init(0xffffffff);
 
// initialize cheapo BLM
BLM_CHEAPO_Init(0);
 
// start task
xTaskCreate(TASK_Period_1mS, (signed portCHAR *)"1mS", configMINIMAL_STACK_SIZE, NULL, PRIORITY_TASK_PERIOD_1mS, NULL);
 
}
 
 
/////////////////////////////////////////////////////////////////////////////
// This task is running endless in background
/////////////////////////////////////////////////////////////////////////////
void APP_Background(void)
{
// endless loop
while( 1 ) {
// toggle the state of all LEDs (allows to measure the execution speed with a scope)
MIOS32_BOARD_LED_Set(0xffffffff, ~MIOS32_BOARD_LED_Get());
 
}
}
 
 
/////////////////////////////////////////////////////////////////////////////
// This hook is called when a MIDI package has been received
/////////////////////////////////////////////////////////////////////////////
void APP_MIDI_NotifyPackage(mios32_midi_port_t port, mios32_midi_package_t midi_package)
{
}
 
 
/////////////////////////////////////////////////////////////////////////////
// This hook is called before the shift register chain is scanned
/////////////////////////////////////////////////////////////////////////////
void APP_SRIO_ServicePrepare(void)
{
// -> BLM_CHEAPO driver
BLM_CHEAPO_PrepareCol();
}
 
 
/////////////////////////////////////////////////////////////////////////////
// This hook is called after the shift register chain has been scanned
/////////////////////////////////////////////////////////////////////////////
void APP_SRIO_ServiceFinish(void)
{
// -> BLM_CHEAPO driver
BLM_CHEAPO_GetRow();
}
 
 
/////////////////////////////////////////////////////////////////////////////
// This hook is called when a button has been toggled
// pin_value is 1 when button released, and 0 when button pressed
/////////////////////////////////////////////////////////////////////////////
void APP_DIN_NotifyToggle(u32 pin, u32 pin_value)
{
}
 
 
/////////////////////////////////////////////////////////////////////////////
// This hook is called when an encoder has been moved
// incrementer is positive when encoder has been turned clockwise, else
// it is negative
/////////////////////////////////////////////////////////////////////////////
void APP_ENC_NotifyChange(u32 encoder, s32 incrementer)
{
}
 
 
/////////////////////////////////////////////////////////////////////////////
// This hook is called when a pot has been moved
/////////////////////////////////////////////////////////////////////////////
void APP_AIN_NotifyChange(u32 pin, u32 pin_value)
{
}
 
 
/////////////////////////////////////////////////////////////////////////////
// This task handles the buttons
/////////////////////////////////////////////////////////////////////////////
void APP_BLM_CHEAPO_NotifyToggle(u32 pin, u32 pin_value)
{
MIOS32_MIDI_SendDebugMessage("Pin:%d Value:%d\n", pin, pin_value);
 
// forward to LED
// note that button value is inverted (1 if depressed)
BLM_CHEAPO_DOUT_PinSet(pin, pin_value ? 0 : 1);
}
 
static void TASK_Period_1mS(void *pvParameters)
{
while( 1 ) {
vTaskDelay(1 / portTICK_RATE_MS);
 
// -> BLM_CHEAPO driver
BLM_CHEAPO_ButtonHandler(APP_BLM_CHEAPO_NotifyToggle);
}
}
Property changes:
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: blm_cheapo/app.h
===================================================================
--- blm_cheapo/app.h (revision 0)
+++ blm_cheapo/app.h (revision 1302)
@@ -0,0 +1,47 @@
+// $Id$
+/*
+ * Header file of application
+ *
+ * ==========================================================================
+ *
+ * Copyright (C) <year> <your name> (<your email address>)
+ * Licensed for personal non-commercial use only.
+ * All other rights reserved.
+ *
+ * ==========================================================================
+ */
+
+#ifndef _APP_H
+#define _APP_H
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Global definitions
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Global Types
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Prototypes
+/////////////////////////////////////////////////////////////////////////////
+
+extern void APP_Init(void);
+extern void APP_Background(void);
+extern void APP_MIDI_NotifyPackage(mios32_midi_port_t port, mios32_midi_package_t midi_package);
+extern void APP_SRIO_ServicePrepare(void);
+extern void APP_SRIO_ServiceFinish(void);
+extern void APP_DIN_NotifyToggle(u32 pin, u32 pin_value);
+extern void APP_ENC_NotifyChange(u32 encoder, s32 incrementer);
+extern void APP_AIN_NotifyChange(u32 pin, u32 pin_value);
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Export global variables
+/////////////////////////////////////////////////////////////////////////////
+
+
+#endif /* _APP_H */
/blm_cheapo/app.h
Property changes:
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: blm_cheapo/mios32_config.h
===================================================================
--- blm_cheapo/mios32_config.h (revision 0)
+++ blm_cheapo/mios32_config.h (revision 1302)
@@ -0,0 +1,18 @@
+// $Id$
+/*
+ * Local MIOS32 configuration file
+ *
+ * this file allows to disable (or re-configure) default functions of MIOS32
+ * available switches are listed in $MIOS32_PATH/modules/mios32/MIOS32_CONFIG.txt
+ *
+ */
+
+#ifndef _MIOS32_CONFIG_H
+#define _MIOS32_CONFIG_H
+
+// The boot message which is print during startup and returned on a SysEx query
+#define MIOS32_LCD_BOOT_MSG_LINE1 "App. Template"
+#define MIOS32_LCD_BOOT_MSG_LINE2 "(C) 2009 <your name>"
+
+
+#endif /* _MIOS32_CONFIG_H */
/blm_cheapo/mios32_config.h
Property changes:
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: blm_cheapo/Makefile
===================================================================
--- blm_cheapo/Makefile (revision 0)
+++ blm_cheapo/Makefile (revision 1302)
@@ -0,0 +1,57 @@
+# $Id$
+
+################################################################################
+# following setup taken from environment variables
+################################################################################
+
+PROCESSOR = $(MIOS32_PROCESSOR)
+FAMILY = $(MIOS32_FAMILY)
+BOARD = $(MIOS32_BOARD)
+LCD = $(MIOS32_LCD)
+
+
+################################################################################
+# Source Files, include paths and libraries
+################################################################################
+
+THUMB_SOURCE = app.c
+
+# (following source stubs not relevant for Cortex M3 derivatives)
+THUMB_AS_SOURCE =
+ARM_SOURCE =
+ARM_AS_SOURCE =
+
+C_INCLUDE = -I .
+A_INCLUDE = -I .
+
+LIBS =
+
+
+################################################################################
+# Remaining variables
+################################################################################
+
+LD_FILE = $(MIOS32_PATH)/etc/ld/$(FAMILY)/$(PROCESSOR).ld
+PROJECT = project
+
+DEBUG = -g
+OPTIMIZE = -Os
+
+CFLAGS = $(DEBUG) $(OPTIMIZE)
+
+
+################################################################################
+# Include source modules via additional makefiles
+################################################################################
+
+# sources of programming model
+include $(MIOS32_PATH)/programming_models/traditional/programming_model.mk
+
+# BLM_CHEAPO driver
+include $(MIOS32_PATH)/modules/blm_cheapo/blm_cheapo.mk
+
+# application specific LCD driver (selected via makefile variable)
+include $(MIOS32_PATH)/modules/app_lcd/$(LCD)/app_lcd.mk
+
+# common make rules
+include $(MIOS32_PATH)/include/makefile/common.mk
/blm_cheapo/Makefile
Property changes:
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property