Subversion Repositories svn.mios32

Compare Revisions

Ignore whitespace Rev 1685 → Rev 1686

/trunk/apps/examples/max72xx/app.c
New file
0,0 → 1,115
// $Id$
/*
* MAX72xx usage example
*
* ==========================================================================
*
* Copyright (C) 2013 Thorsten Klose (Thorsten.Klose@gmx.de)
* Licensed for personal non-commercial use only.
* All other rights reserved.
*
* ==========================================================================
*/
 
/////////////////////////////////////////////////////////////////////////////
// Include files
/////////////////////////////////////////////////////////////////////////////
 
#include <mios32.h>
 
#include <max72xx.h>
 
#include "app.h"
 
 
/////////////////////////////////////////////////////////////////////////////
// This hook is called after startup to initialize the application
/////////////////////////////////////////////////////////////////////////////
void APP_Init(void)
{
// initialize all LEDs
MIOS32_BOARD_LED_Init(0xffffffff);
 
// initialize all MAX72xx
MAX72XX_Init(0);
}
 
 
/////////////////////////////////////////////////////////////////////////////
// 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)
{
if( midi_package.type == CC ) {
u8 chain = 0; // testing only the first chain
 
int device = midi_package.cc_number - 16;
if( device >= 0 && device < MAX72XX_NumDevicesPerChainGet(chain) ) {
//s32 MAX72XX_AllDigitsSet(u8 chain, u8 device, u8 *values)
MIOS32_MIDI_SendDebugMessage("Setting pattern for device #%d to %d\n", device, midi_package.value);
MAX72XX_DigitSet(chain, device, 0, midi_package.value);
MAX72XX_DigitSet(chain, device, 1, midi_package.value);
MAX72XX_DigitSet(chain, device, 2, midi_package.value);
MAX72XX_UpdateAllChains();
} else {
MIOS32_MIDI_SendDebugMessage("No MAX72xx device mapped to CC#%d\n", midi_package.cc_number);
}
}
}
 
 
/////////////////////////////////////////////////////////////////////////////
// This hook is called before the shift register chain is scanned
/////////////////////////////////////////////////////////////////////////////
void APP_SRIO_ServicePrepare(void)
{
}
 
 
/////////////////////////////////////////////////////////////////////////////
// This hook is called after the shift register chain has been scanned
/////////////////////////////////////////////////////////////////////////////
void APP_SRIO_ServiceFinish(void)
{
}
 
 
/////////////////////////////////////////////////////////////////////////////
// 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)
{
}
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: max72xx/app.h
===================================================================
--- max72xx/app.h (revision 0)
+++ max72xx/app.h (revision 1686)
@@ -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 */
/max72xx/app.h
Property changes:
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: max72xx/mios32_config.h
===================================================================
--- max72xx/mios32_config.h (revision 0)
+++ max72xx/mios32_config.h (revision 1686)
@@ -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 "MAX72xx Example"
+#define MIOS32_LCD_BOOT_MSG_LINE2 "(C) 2013 T.Klose"
+
+
+#endif /* _MIOS32_CONFIG_H */
/max72xx/mios32_config.h
Property changes:
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: max72xx/README.txt
===================================================================
--- max72xx/README.txt (revision 0)
+++ max72xx/README.txt (revision 1686)
@@ -0,0 +1,23 @@
+$Id$
+
+MAX72xx example
+===============================================================================
+Copyright (C) 2013 Thorsten Klose (tk@midibox.org)
+Licensed for personal non-commercial use only.
+All other rights reserved.
+===============================================================================
+
+Required tools:
+ -> http://www.ucapps.de/mio32_c.html
+
+===============================================================================
+
+Required hardware:
+ o MBHP_CORE_STM32 or MBHP_CORE_LPC17
+ o at least one MAX7219 or MAX7221 connected to J19 of the core module
+
+===============================================================================
+
+<Application Description>
+
+===============================================================================
/max72xx/README.txt
Property changes:
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: max72xx/Makefile
===================================================================
--- max72xx/Makefile (revision 0)
+++ max72xx/Makefile (revision 1686)
@@ -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
+
+# application specific LCD driver (selected via makefile variable)
+include $(MIOS32_PATH)/modules/app_lcd/$(LCD)/app_lcd.mk
+
+# MAX72xx driver
+include $(MIOS32_PATH)/modules/max72xx/max72xx.mk
+
+# common make rules
+include $(MIOS32_PATH)/include/makefile/common.mk
/max72xx/Makefile
Property changes:
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property