mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-20 05:21:59 -04:00
Continue FX16 demo development.
This commit is contained in:
parent
7551ede806
commit
d61373702a
220
Demo/MB96350_Softune_Dice_Kit/DiceTask.c
Normal file
220
Demo/MB96350_Softune_Dice_Kit/DiceTask.c
Normal file
|
@ -0,0 +1,220 @@
|
||||||
|
/*
|
||||||
|
FreeRTOS.org V5.1.1 - Copyright (C) 2003-2008 Richard Barry.
|
||||||
|
|
||||||
|
This file is part of the FreeRTOS.org distribution.
|
||||||
|
|
||||||
|
FreeRTOS.org 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.
|
||||||
|
|
||||||
|
FreeRTOS.org 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 FreeRTOS.org; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
A special exception to the GPL can be applied should you wish to distribute
|
||||||
|
a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||||
|
the source code for any proprietary components. See the licensing section
|
||||||
|
of http://www.FreeRTOS.org for full details of how and when the exception
|
||||||
|
can be applied.
|
||||||
|
|
||||||
|
***************************************************************************
|
||||||
|
***************************************************************************
|
||||||
|
* *
|
||||||
|
* SAVE TIME AND MONEY! We can port FreeRTOS.org to your own hardware, *
|
||||||
|
* and even write all or part of your application on your behalf. *
|
||||||
|
* See http://www.OpenRTOS.com for details of the services we provide to *
|
||||||
|
* expedite your project. *
|
||||||
|
* *
|
||||||
|
***************************************************************************
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
Please ensure to read the configuration and relevant port sections of the
|
||||||
|
online documentation.
|
||||||
|
|
||||||
|
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||||
|
contact details.
|
||||||
|
|
||||||
|
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||||
|
critical systems.
|
||||||
|
|
||||||
|
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||||
|
licensing and training services.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
|
||||||
|
#define diceMIN 1
|
||||||
|
#define diceMAX 6
|
||||||
|
#define diceRUN_MIN 600000L
|
||||||
|
#define diceRUN_MAX 1200000L
|
||||||
|
|
||||||
|
#define diceSTATE_STOPPED 0
|
||||||
|
#define diceSTATE_STARTUP 1
|
||||||
|
#define diceSTATE_RUNNING 2
|
||||||
|
|
||||||
|
static unsigned char prvButtonHit( unsigned char ucIndex );
|
||||||
|
|
||||||
|
static const char cDisplaySegments[ 2 ][ 11 ] =
|
||||||
|
{
|
||||||
|
{ 0x48, 0xeb, 0x8c, 0x89, 0x2b, 0x19, 0x18, 0xcb, 0x08, 0x09, 0xf7 },
|
||||||
|
{ 0xa0, 0xf3, 0xc4, 0xc1, 0x93, 0x89, 0x88, 0xe3, 0x80, 0x81, 0x7f }
|
||||||
|
};
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
void vDiceTask( void *pvParameters )
|
||||||
|
{
|
||||||
|
char cDiceState = diceSTATE_STOPPED;
|
||||||
|
unsigned char ucDiceValue, ucIndex;
|
||||||
|
unsigned long ulDice1RunTime, ulDiceDelay, ulDiceDelayReload;
|
||||||
|
|
||||||
|
ucIndex = ( unsigned char ) pvParameters;
|
||||||
|
|
||||||
|
for( ;; )
|
||||||
|
{
|
||||||
|
switch( cDiceState )
|
||||||
|
{
|
||||||
|
case diceSTATE_STOPPED:
|
||||||
|
|
||||||
|
if( prvButtonHit( ucIndex ) == pdTRUE )
|
||||||
|
{
|
||||||
|
ulDice1RunTime = diceRUN_MIN;
|
||||||
|
srand( ( unsigned char ) ulDice1RunTime );
|
||||||
|
cDiceState = diceSTATE_STARTUP;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case diceSTATE_STARTUP:
|
||||||
|
|
||||||
|
if( ulDice1RunTime < diceRUN_MAX ) // variable running time
|
||||||
|
{
|
||||||
|
ulDice1RunTime++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ulDice1RunTime = diceRUN_MIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( PDR00_P0 == 0 ) // Key SW2:INT8 released
|
||||||
|
{
|
||||||
|
ulDiceDelay = 1;
|
||||||
|
ulDiceDelayReload = 1;
|
||||||
|
cDiceState = diceSTATE_RUNNING;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case diceSTATE_RUNNING:
|
||||||
|
|
||||||
|
ulDice1RunTime--;
|
||||||
|
ulDiceDelay--;
|
||||||
|
|
||||||
|
if( !ulDiceDelay )
|
||||||
|
{
|
||||||
|
ucDiceValue = rand() % 6 + 1;
|
||||||
|
PDR03 = ( PDR03 | 0xf7 ) & cDisplaySegments[ ucIndex ][ ucDiceValue ];
|
||||||
|
ulDiceDelayReload = ulDiceDelayReload + 100;
|
||||||
|
ulDiceDelay = ulDiceDelayReload;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ulDice1RunTime == 0 ) // dice stopped
|
||||||
|
{
|
||||||
|
PDR03 = ( PDR03 | 0xf7 ) & cDisplaySegments[ ucIndex ][ rand() % 6 + 1 ];
|
||||||
|
cDiceState = diceSTATE_STOPPED;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static unsigned char prvButtonHit( unsigned char ucIndex )
|
||||||
|
{
|
||||||
|
if( ( ucIndex == 0 ) && PDR00_P0 )
|
||||||
|
{
|
||||||
|
return pdTRUE;
|
||||||
|
}
|
||||||
|
else if( ( ucIndex == 1 ) && PDR00_P1 )
|
||||||
|
{
|
||||||
|
return pdTRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return pdFALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
|
// DICE 2
|
||||||
|
|
||||||
|
switch (dice2state)
|
||||||
|
{
|
||||||
|
case 0x00: // dice2 stopped
|
||||||
|
if( PDR00_P1 == 1) // Key SW3:INT9 pressed
|
||||||
|
{
|
||||||
|
dice2run = diceRUN_MIN;
|
||||||
|
srand((unsigned char)ulDice1RunTime);
|
||||||
|
dice2state = 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x01: // dice2 startup
|
||||||
|
if( dice2run < diceRUN_MAX) // variable running time
|
||||||
|
dice2run++;
|
||||||
|
else
|
||||||
|
dice2run = diceRUN_MIN;
|
||||||
|
|
||||||
|
if( dice2 == diceMAX) // simple 'random' number
|
||||||
|
dice2 = diceMIN;
|
||||||
|
else dice2++;
|
||||||
|
|
||||||
|
if( PDR00_P1 == 0) // Key SW3:INT9 released
|
||||||
|
{
|
||||||
|
dice2delay = 1;
|
||||||
|
dice2delayrld = 1;
|
||||||
|
dice2state = 0x02;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x02: // dice2 running
|
||||||
|
dice2run--;
|
||||||
|
dice2delay--;
|
||||||
|
|
||||||
|
if( !dice2delay)
|
||||||
|
{
|
||||||
|
do // get new random number
|
||||||
|
{
|
||||||
|
temp = rand() % 6 + 1;
|
||||||
|
}
|
||||||
|
while (temp == dice2);
|
||||||
|
dice2 = temp;
|
||||||
|
|
||||||
|
PDR05 = DICE7SEG2[dice2];
|
||||||
|
dice2delayrld = dice2delayrld + 100;
|
||||||
|
dice2delay = dice2delayrld;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( dice2run == 0) // dice stopped
|
||||||
|
{
|
||||||
|
PDR05 = DICE7SEG2[rand() % 6 + 1];
|
||||||
|
dice2state = 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
}//switch (dice2state)
|
||||||
|
|
||||||
|
} // while(1)
|
||||||
|
#endif
|
||||||
|
|
57
Demo/MB96350_Softune_Dice_Kit/DiceTask.h
Normal file
57
Demo/MB96350_Softune_Dice_Kit/DiceTask.h
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
/*
|
||||||
|
FreeRTOS.org V5.1.1 - Copyright (C) 2003-2008 Richard Barry.
|
||||||
|
|
||||||
|
This file is part of the FreeRTOS.org distribution.
|
||||||
|
|
||||||
|
FreeRTOS.org 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.
|
||||||
|
|
||||||
|
FreeRTOS.org 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 FreeRTOS.org; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
A special exception to the GPL can be applied should you wish to distribute
|
||||||
|
a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||||
|
the source code for any proprietary components. See the licensing section
|
||||||
|
of http://www.FreeRTOS.org for full details of how and when the exception
|
||||||
|
can be applied.
|
||||||
|
|
||||||
|
***************************************************************************
|
||||||
|
***************************************************************************
|
||||||
|
* *
|
||||||
|
* SAVE TIME AND MONEY! We can port FreeRTOS.org to your own hardware, *
|
||||||
|
* and even write all or part of your application on your behalf. *
|
||||||
|
* See http://www.OpenRTOS.com for details of the services we provide to *
|
||||||
|
* expedite your project. *
|
||||||
|
* *
|
||||||
|
***************************************************************************
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
Please ensure to read the configuration and relevant port sections of the
|
||||||
|
online documentation.
|
||||||
|
|
||||||
|
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||||
|
contact details.
|
||||||
|
|
||||||
|
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||||
|
critical systems.
|
||||||
|
|
||||||
|
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||||
|
licensing and training services.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DICE_TASK_H
|
||||||
|
#define DICE_TASK_H
|
||||||
|
|
||||||
|
void vDiceTask( void *pvParameters );
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ the ComTest tasks will be included in place of the trace task. */
|
||||||
#define configCLKP1_CLOCK_HZ ( ( unsigned portLONG ) 56000000 ) /* Clock setup from start.asm in the demo application. */
|
#define configCLKP1_CLOCK_HZ ( ( unsigned portLONG ) 56000000 ) /* Clock setup from start.asm in the demo application. */
|
||||||
#define configTICK_RATE_HZ ( (portTickType) 1000 )
|
#define configTICK_RATE_HZ ( (portTickType) 1000 )
|
||||||
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 6 )
|
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 6 )
|
||||||
#define configTOTAL_HEAP_SIZE ( (size_t) (8000) )
|
#define configTOTAL_HEAP_SIZE ( (size_t) (5000) )
|
||||||
#define configMAX_TASK_NAME_LEN ( 20 )
|
#define configMAX_TASK_NAME_LEN ( 20 )
|
||||||
#define configUSE_16_BIT_TICKS 1
|
#define configUSE_16_BIT_TICKS 1
|
||||||
#define configIDLE_SHOULD_YIELD 1
|
#define configIDLE_SHOULD_YIELD 1
|
||||||
|
|
|
@ -16,4 +16,5 @@
|
||||||
-a "C:\E\Dev\FreeRTOS\WorkingCopy3\Demo\MB96350_Softune_Dice_Kit\OBJ\__STD_LIB_sbrk.obj"
|
-a "C:\E\Dev\FreeRTOS\WorkingCopy3\Demo\MB96350_Softune_Dice_Kit\OBJ\__STD_LIB_sbrk.obj"
|
||||||
-a "C:\E\Dev\FreeRTOS\WorkingCopy3\Demo\MB96350_Softune_Dice_Kit\OBJ\heap_1.obj"
|
-a "C:\E\Dev\FreeRTOS\WorkingCopy3\Demo\MB96350_Softune_Dice_Kit\OBJ\heap_1.obj"
|
||||||
-a "C:\E\Dev\FreeRTOS\WorkingCopy3\Demo\MB96350_Softune_Dice_Kit\OBJ\croutine.obj"
|
-a "C:\E\Dev\FreeRTOS\WorkingCopy3\Demo\MB96350_Softune_Dice_Kit\OBJ\croutine.obj"
|
||||||
|
-a "C:\E\Dev\FreeRTOS\WorkingCopy3\Demo\MB96350_Softune_Dice_Kit\OBJ\DiceTask.obj"
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
-Xals
|
-Xals
|
||||||
-Xalr
|
-Xalr
|
||||||
-na
|
-na
|
||||||
|
-NCI0302LIB
|
||||||
-w 2
|
-w 2
|
||||||
-cwno
|
-cwno
|
||||||
-a
|
-a
|
||||||
|
@ -33,4 +34,5 @@
|
||||||
"C:\E\Dev\FreeRTOS\WorkingCopy3\Demo\MB96350_Softune_Dice_Kit\OBJ\__STD_LIB_sbrk.obj"
|
"C:\E\Dev\FreeRTOS\WorkingCopy3\Demo\MB96350_Softune_Dice_Kit\OBJ\__STD_LIB_sbrk.obj"
|
||||||
"C:\E\Dev\FreeRTOS\WorkingCopy3\Demo\MB96350_Softune_Dice_Kit\OBJ\heap_1.obj"
|
"C:\E\Dev\FreeRTOS\WorkingCopy3\Demo\MB96350_Softune_Dice_Kit\OBJ\heap_1.obj"
|
||||||
"C:\E\Dev\FreeRTOS\WorkingCopy3\Demo\MB96350_Softune_Dice_Kit\OBJ\croutine.obj"
|
"C:\E\Dev\FreeRTOS\WorkingCopy3\Demo\MB96350_Softune_Dice_Kit\OBJ\croutine.obj"
|
||||||
|
"C:\E\Dev\FreeRTOS\WorkingCopy3\Demo\MB96350_Softune_Dice_Kit\OBJ\DiceTask.obj"
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ PrjInfo-0=Debug
|
||||||
Active=Debug
|
Active=Debug
|
||||||
|
|
||||||
[MEMBER]
|
[MEMBER]
|
||||||
F0=14
|
F0=15
|
||||||
F1=0 f Include Files
|
F1=0 f Include Files
|
||||||
F2=0 f FreeRTOS Source
|
F2=0 f FreeRTOS Source
|
||||||
F3=0 c ..\..\Source\portable\Softune\MB96340\__STD_LIB_sbrk.c
|
F3=0 c ..\..\Source\portable\Softune\MB96340\__STD_LIB_sbrk.c
|
||||||
|
@ -28,10 +28,11 @@ F7=0 c ..\..\Source\portable\Softune\MB96340\port.c
|
||||||
F8=0 c ..\..\Source\queue.c
|
F8=0 c ..\..\Source\queue.c
|
||||||
F9=0 c ..\..\Source\tasks.c
|
F9=0 c ..\..\Source\tasks.c
|
||||||
F10=0 f Demo Source
|
F10=0 f Demo Source
|
||||||
F11=0 c main.c
|
F11=0 c DiceTask.c
|
||||||
F12=0 a mb96356rs.asm
|
F12=0 c main.c
|
||||||
F13=0 a START.ASM
|
F13=0 a mb96356rs.asm
|
||||||
F14=0 c vectors.c
|
F14=0 a START.ASM
|
||||||
|
F15=0 c vectors.c
|
||||||
|
|
||||||
[OPTIONFILE]
|
[OPTIONFILE]
|
||||||
FILE=options.dat
|
FILE=options.dat
|
||||||
|
@ -48,12 +49,22 @@ LST=LST\
|
||||||
OPT=OPT\
|
OPT=OPT\
|
||||||
|
|
||||||
[MEMBER-Debug]
|
[MEMBER-Debug]
|
||||||
F0=12
|
F0=13
|
||||||
F1=0 m 1 ABS\RTOSDemo.abs
|
F1=0 m 1 ABS\RTOSDemo.abs
|
||||||
F2=1 c 1 vectors.c
|
F2=2 c 1 vectors.c
|
||||||
F2-1=- mb96356rs.h
|
F2-1=- mb96356rs.h
|
||||||
F3=1 c 1 main.c
|
F2-2=- FreeRTOSConfig.h
|
||||||
|
F3=10 c 1 main.c
|
||||||
F3-1=- mb96356rs.h
|
F3-1=- mb96356rs.h
|
||||||
|
F3-2=- ..\..\Source\Include\FreeRTOS.h
|
||||||
|
F3-3=- ..\..\..\..\..\..\devtools\Softune\LIB\907\INCLUDE\stddef.h
|
||||||
|
F3-4=- ..\..\Source\Include\projdefs.h
|
||||||
|
F3-5=- FreeRTOSConfig.h
|
||||||
|
F3-6=- ..\..\Source\Include\portable.h
|
||||||
|
F3-7=- ..\..\Source\portable\Softune\MB96340\portmacro.h
|
||||||
|
F3-8=- DiceTask.h
|
||||||
|
F3-9=- ..\..\Source\Include\task.h
|
||||||
|
F3-10=- ..\..\Source\Include\list.h
|
||||||
F4=0 a 1 mb96356rs.asm
|
F4=0 a 1 mb96356rs.asm
|
||||||
F5=0 a 1 START.ASM
|
F5=0 a 1 START.ASM
|
||||||
F6=14 c 1 ..\..\Source\tasks.c
|
F6=14 c 1 ..\..\Source\tasks.c
|
||||||
|
@ -131,6 +142,16 @@ F12-7=- ..\..\Source\portable\Softune\MB96340\portmacro.h
|
||||||
F12-8=- ..\..\Source\Include\task.h
|
F12-8=- ..\..\Source\Include\task.h
|
||||||
F12-9=- ..\..\Source\Include\list.h
|
F12-9=- ..\..\Source\Include\list.h
|
||||||
F12-10=- ..\..\Source\Include\croutine.h
|
F12-10=- ..\..\Source\Include\croutine.h
|
||||||
|
F13=9 c 1 DiceTask.c
|
||||||
|
F13-1=- ..\..\Source\Include\FreeRTOS.h
|
||||||
|
F13-2=- ..\..\..\..\..\..\devtools\Softune\LIB\907\INCLUDE\stddef.h
|
||||||
|
F13-3=- ..\..\Source\Include\projdefs.h
|
||||||
|
F13-4=- FreeRTOSConfig.h
|
||||||
|
F13-5=- mb96356rs.h
|
||||||
|
F13-6=- ..\..\Source\Include\portable.h
|
||||||
|
F13-7=- ..\..\Source\portable\Softune\MB96340\portmacro.h
|
||||||
|
F13-8=- ..\..\Source\Include\task.h
|
||||||
|
F13-9=- ..\..\Source\Include\list.h
|
||||||
|
|
||||||
[BUILDMODE-Debug]
|
[BUILDMODE-Debug]
|
||||||
kernel=0
|
kernel=0
|
||||||
|
|
|
@ -18,9 +18,5 @@ AutoLoad=1
|
||||||
WSP=C:\E\Dev\FreeRTOS\WorkingCopy3\Demo\MB96350_Softune_Dice_Kit\
|
WSP=C:\E\Dev\FreeRTOS\WorkingCopy3\Demo\MB96350_Softune_Dice_Kit\
|
||||||
|
|
||||||
[EditState]
|
[EditState]
|
||||||
STATE-1=..\..\Source\portable\Softune\MB96340\portmacro.h:54
|
Count=0
|
||||||
STATE-2=..\..\source\portable\softune\mb96340\port.c:52
|
|
||||||
STATE-3=START.ASM:1
|
|
||||||
STATE-4=main.c:202
|
|
||||||
Count=4
|
|
||||||
|
|
||||||
|
|
|
@ -1,201 +1,124 @@
|
||||||
/* THIS SAMPLE CODE IS PROVIDED AS IS AND IS SUBJECT TO ALTERATIONS. FUJITSU */
|
/*
|
||||||
/* MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR */
|
FreeRTOS.org V5.1.1 - Copyright (C) 2003-2008 Richard Barry.
|
||||||
/* ELIGIBILITY FOR ANY PURPOSES. */
|
|
||||||
/* (C) Fujitsu Microelectronics Europe GmbH */
|
|
||||||
/*---------------------------------------------------------------------------
|
|
||||||
MAIN.C
|
|
||||||
- description
|
|
||||||
- See README.TXT for project description and disclaimer.
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
This file is part of the FreeRTOS.org distribution.
|
||||||
|
|
||||||
|
FreeRTOS.org 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.
|
||||||
|
|
||||||
#include "mb96356rs.h"
|
FreeRTOS.org 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.
|
||||||
|
|
||||||
#define DICE_MIN 1
|
You should have received a copy of the GNU General Public License
|
||||||
#define DICE_MAX 6
|
along with FreeRTOS.org; if not, write to the Free Software
|
||||||
#define DICERUN_MIN 600000L
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#define DICERUN_MAX 1200000L
|
|
||||||
|
|
||||||
const char DICE7SEG1[11]={0x48, 0xeb, 0x8c, 0x89, 0x2b, 0x19, 0x18, 0xcb, 0x08, 0x09, 0xf7};
|
A special exception to the GPL can be applied should you wish to distribute
|
||||||
const char DICE7SEG2[11]={0xa0, 0xf3, 0xc4, 0xc1, 0x93, 0x89, 0x88, 0xe3, 0x80, 0x81, 0x7f};
|
a combined work that includes FreeRTOS.org, without being obliged to provide
|
||||||
|
the source code for any proprietary components. See the licensing section
|
||||||
|
of http://www.FreeRTOS.org for full details of how and when the exception
|
||||||
|
can be applied.
|
||||||
|
|
||||||
unsigned char temp;
|
***************************************************************************
|
||||||
unsigned char dice1, dice2;
|
***************************************************************************
|
||||||
unsigned long dice1run, dice2run;
|
* *
|
||||||
unsigned long dice1state, dice2state;
|
* SAVE TIME AND MONEY! We can port FreeRTOS.org to your own hardware, *
|
||||||
unsigned long dice1delay, dice2delay;
|
* and even write all or part of your application on your behalf. *
|
||||||
unsigned long dice1delayrld, dice2delayrld;
|
* See http://www.OpenRTOS.com for details of the services we provide to *
|
||||||
|
* expedite your project. *
|
||||||
|
* *
|
||||||
|
***************************************************************************
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
/*===========================================================================*/
|
Please ensure to read the configuration and relevant port sections of the
|
||||||
/*====== MAIN ===============================================================*/
|
online documentation.
|
||||||
/*===========================================================================*/
|
|
||||||
|
|
||||||
void main(void)
|
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||||
{
|
contact details.
|
||||||
InitIrqLevels();
|
|
||||||
__set_il(7); // allow all levels
|
|
||||||
__EI(); // globally enable interrupts
|
|
||||||
|
|
||||||
// initialize I/O-ports
|
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||||
|
critical systems.
|
||||||
|
|
||||||
PIER00 = 0x03; // Enable P00_0/INT8 and P00_1/INT9 as input
|
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||||
PDR00 = 0x00;
|
licensing and training services.
|
||||||
DDR00 = 0xfc; // P00_0: SW2(INT8) P00_1: SW3(INT9)
|
|
||||||
|
|
||||||
/* Do not use when Background Debugging is enabled
|
|
||||||
PIER01 = 0x04; // enable P01_2/SIN3 as input
|
|
||||||
PDR01 = 0x08; // SOT3 = 1
|
|
||||||
DDR01 = 0xfb; // SIN3 = input
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
PIER02 = 0x00; // All inputs are disabled on this port
|
/* Kernel includes. */
|
||||||
PDR02 = 0x00;
|
#include "FreeRTOS.h"
|
||||||
DDR02 = 0xff;
|
#include "Task.h"
|
||||||
|
|
||||||
PIER03 = 0x00; // All inputs are disabled on this port
|
/* Demo includes. */
|
||||||
PDR03 = 0xff;
|
#include "DiceTask.h"
|
||||||
DDR03 = 0xff; // Set Port3 as output (7Segment Display)
|
|
||||||
|
|
||||||
PIER04 = 0x04; // Enable P04_2/RX as input
|
static void prvSetupHardware( void );
|
||||||
PDR04 = 0x08; // CAN TX = 1
|
|
||||||
DDR04 = 0xfb; // CAN RX = input
|
|
||||||
|
|
||||||
PIER05 = 0x00; // All inputs are disabled on this port
|
/*-----------------------------------------------------------*/
|
||||||
ADER1 = 0; // Use Port 5 as I/O-Port
|
|
||||||
PDR05 = 0x7f;
|
|
||||||
DDR05 = 0xff; // Set Port5 as output (7Segment Display)
|
|
||||||
|
|
||||||
PIER06 = 0x00; // All inputs are disabled on this port
|
void main( void )
|
||||||
PDR06 = 0x00;
|
{
|
||||||
DDR06 = 0xff;
|
prvSetupHardware();
|
||||||
|
|
||||||
while (1)
|
xTaskCreate( vDiceTask, ( signed char * ) "Dice", configMINIMAL_STACK_SIZE, ( void * ) 0, tskIDLE_PRIORITY, NULL );
|
||||||
{
|
|
||||||
// DICE 1
|
|
||||||
|
|
||||||
switch (dice1state)
|
vTaskStartScheduler();
|
||||||
{
|
|
||||||
case 0x00: // dice1 stopped
|
|
||||||
if (PDR00_P0 == 1) // Key SW2:INT8 pressed
|
|
||||||
{
|
|
||||||
dice1run = DICERUN_MIN;
|
|
||||||
srand((unsigned char)dice1run);
|
|
||||||
dice1state = 0x01;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x01: // dice1 startup
|
|
||||||
if (dice1run < DICERUN_MAX) // variable running time
|
|
||||||
dice1run++;
|
|
||||||
else
|
|
||||||
dice1run = DICERUN_MIN;
|
|
||||||
|
|
||||||
if (PDR00_P0 == 0) // Key SW2:INT8 released
|
|
||||||
{
|
|
||||||
dice1delay = 1;
|
|
||||||
dice1delayrld = 1;
|
|
||||||
dice1state = 0x02;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x02: // dice1 running
|
|
||||||
dice1run--;
|
|
||||||
dice1delay--;
|
|
||||||
|
|
||||||
if (!dice1delay)
|
|
||||||
{
|
|
||||||
do // get new random number
|
|
||||||
{
|
|
||||||
temp = rand() % 6 + 1;
|
|
||||||
}
|
|
||||||
while (temp == dice1);
|
|
||||||
dice1 = temp;
|
|
||||||
|
|
||||||
PDR03 = (PDR03 | 0xf7) & DICE7SEG1[dice1];
|
|
||||||
dice1delayrld = dice1delayrld + 100;
|
|
||||||
dice1delay = dice1delayrld;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dice1run == 0) // dice stopped
|
|
||||||
{
|
|
||||||
PDR03 = (PDR03 | 0xf7) & DICE7SEG1[rand() % 6 + 1];
|
|
||||||
dice1state = 0x00;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
}//switch (dice1state)
|
|
||||||
|
|
||||||
|
|
||||||
// DICE 2
|
|
||||||
|
|
||||||
switch (dice2state)
|
|
||||||
{
|
|
||||||
case 0x00: // dice2 stopped
|
|
||||||
if (PDR00_P1 == 1) // Key SW3:INT9 pressed
|
|
||||||
{
|
|
||||||
dice2run = DICERUN_MIN;
|
|
||||||
srand((unsigned char)dice1run);
|
|
||||||
dice2state = 0x01;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x01: // dice2 startup
|
|
||||||
if (dice2run < DICERUN_MAX) // variable running time
|
|
||||||
dice2run++;
|
|
||||||
else
|
|
||||||
dice2run = DICERUN_MIN;
|
|
||||||
|
|
||||||
if (dice2 == DICE_MAX) // simple 'random' number
|
|
||||||
dice2 = DICE_MIN;
|
|
||||||
else dice2++;
|
|
||||||
|
|
||||||
if (PDR00_P1 == 0) // Key SW3:INT9 released
|
|
||||||
{
|
|
||||||
dice2delay = 1;
|
|
||||||
dice2delayrld = 1;
|
|
||||||
dice2state = 0x02;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x02: // dice2 running
|
|
||||||
dice2run--;
|
|
||||||
dice2delay--;
|
|
||||||
|
|
||||||
if (!dice2delay)
|
|
||||||
{
|
|
||||||
do // get new random number
|
|
||||||
{
|
|
||||||
temp = rand() % 6 + 1;
|
|
||||||
}
|
|
||||||
while (temp == dice2);
|
|
||||||
dice2 = temp;
|
|
||||||
|
|
||||||
PDR05 = DICE7SEG2[dice2];
|
|
||||||
dice2delayrld = dice2delayrld + 100;
|
|
||||||
dice2delay = dice2delayrld;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dice2run == 0) // dice stopped
|
|
||||||
{
|
|
||||||
PDR05 = DICE7SEG2[rand() % 6 + 1];
|
|
||||||
dice2state = 0x00;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
}//switch (dice2state)
|
|
||||||
|
|
||||||
} // while(1)
|
|
||||||
|
|
||||||
|
while( 1 );
|
||||||
}
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void vApplicationIdleHook( void )
|
void vApplicationIdleHook( void )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
static void prvSetupHardware( void )
|
||||||
|
{
|
||||||
|
/* Setup interrupt hardware - interrupts are kept disabled for now to
|
||||||
|
prevent any interrupts attempting to cause a context switch before the
|
||||||
|
scheduler has been started. */
|
||||||
|
InitIrqLevels();
|
||||||
|
portDISABLE_INTERRUPTS();
|
||||||
|
__set_il( 7 );
|
||||||
|
|
||||||
|
/* Enable P00_0/INT8 and P00_1/INT9 as input. */
|
||||||
|
PIER00 = 0x03;
|
||||||
|
PDR00 = 0x00;
|
||||||
|
DDR00 = 0xfc;
|
||||||
|
|
||||||
|
/* Set Port3 as output (7Segment Display). */
|
||||||
|
DDR03 = 0xff;
|
||||||
|
|
||||||
|
/* Enable P04_2/RX as input. */
|
||||||
|
PIER04 = 0x04;
|
||||||
|
|
||||||
|
/* CAN TX = 1. */
|
||||||
|
PDR04 = 0x08;
|
||||||
|
|
||||||
|
/* CAN RX = input. */
|
||||||
|
DDR04 = 0xfb;
|
||||||
|
|
||||||
|
/* All inputs are disabled on this port. */
|
||||||
|
PIER05 = 0x00;
|
||||||
|
|
||||||
|
/* Use Port 5 as I/O-Port. */
|
||||||
|
ADER1 = 0;
|
||||||
|
PDR05 = 0x7f;
|
||||||
|
|
||||||
|
/* Set Port5 as output (7Segment Display). */
|
||||||
|
DDR05 = 0xff;
|
||||||
|
|
||||||
|
/* Disable inputs on the following ports. */
|
||||||
|
PIER02 = 0x00;
|
||||||
|
PDR02 = 0x00;
|
||||||
|
DDR02 = 0xff;
|
||||||
|
PIER03 = 0x00;
|
||||||
|
PDR03 = 0xff;
|
||||||
|
PIER06 = 0x00;
|
||||||
|
PDR06 = 0x00;
|
||||||
|
DDR06 = 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,12 +54,13 @@ $2
|
||||||
-Xals
|
-Xals
|
||||||
-Xalr
|
-Xalr
|
||||||
-na
|
-na
|
||||||
|
-NCI0302LIB
|
||||||
-w 2
|
-w 2
|
||||||
-Xdof
|
-Xdof
|
||||||
$other
|
$other
|
||||||
-Xset_rora
|
-Xset_rora
|
||||||
$time
|
$time
|
||||||
1232226688
|
1233316909
|
||||||
$end
|
$end
|
||||||
$3
|
$3
|
||||||
-dt s,d,r,a
|
-dt s,d,r,a
|
||||||
|
@ -69,7 +70,7 @@ $3
|
||||||
-Xdof
|
-Xdof
|
||||||
$other
|
$other
|
||||||
$time
|
$time
|
||||||
1232226688
|
1233316440
|
||||||
$end
|
$end
|
||||||
$4
|
$4
|
||||||
-Xdof
|
-Xdof
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "mb96356rs.h"
|
#include "mb96356rs.h"
|
||||||
|
#include "FreeRTOSConfig.h"
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------
|
/*---------------------------------------------------------------------------
|
||||||
InitIrqLevels()
|
InitIrqLevels()
|
||||||
|
@ -33,6 +34,8 @@ void InitIrqLevels(void)
|
||||||
ICR = (irq << 8) | DEFAULT_ILM_MASK;
|
ICR = (irq << 8) | DEFAULT_ILM_MASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ICR = ( (54 & 0xFF) << 8 ) | configKERNEL_INTERRUPT_PRIORITY; /* Reload Timer 0 */
|
||||||
|
ICR = ( (12 & 0xFF) << 8 ) | configKERNEL_INTERRUPT_PRIORITY; /* Delayed interrupt of 16FX Family */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------
|
/*---------------------------------------------------------------------------
|
||||||
|
@ -40,8 +43,11 @@ void InitIrqLevels(void)
|
||||||
Add your own prototypes here. Each vector definition needs is proto-
|
Add your own prototypes here. Each vector definition needs is proto-
|
||||||
type. Either do it here or include a header file containing them.
|
type. Either do it here or include a header file containing them.
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
__interrupt void DefaultIRQHandler( void );
|
||||||
|
|
||||||
__interrupt void DefaultIRQHandler (void);
|
extern __interrupt void prvRLT0_TICKISR( void );
|
||||||
|
extern __interrupt void vPortYield( void );
|
||||||
|
extern __interrupt void vPortYieldDelayed( void );
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------
|
/*---------------------------------------------------------------------------
|
||||||
Vector definiton for MB9635x
|
Vector definiton for MB9635x
|
||||||
|
@ -53,7 +59,9 @@ __interrupt void DefaultIRQHandler (void);
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#pragma intvect DefaultIRQHandler 11 /* Non-maskable Interrupt */
|
#pragma intvect DefaultIRQHandler 11 /* Non-maskable Interrupt */
|
||||||
#pragma intvect DefaultIRQHandler 12 /* Delayed Interrupt */
|
|
||||||
|
#pragma intvect vPortYieldDelayed 12 /* Delayed Interrupt */
|
||||||
|
|
||||||
#pragma intvect DefaultIRQHandler 13 /* RC Timer */
|
#pragma intvect DefaultIRQHandler 13 /* RC Timer */
|
||||||
#pragma intvect DefaultIRQHandler 14 /* Main Clock Timer */
|
#pragma intvect DefaultIRQHandler 14 /* Main Clock Timer */
|
||||||
#pragma intvect DefaultIRQHandler 15 /* Sub Clock Timer */
|
#pragma intvect DefaultIRQHandler 15 /* Sub Clock Timer */
|
||||||
|
@ -95,7 +103,7 @@ __interrupt void DefaultIRQHandler (void);
|
||||||
#pragma intvect DefaultIRQHandler 51 /* PPG17 */
|
#pragma intvect DefaultIRQHandler 51 /* PPG17 */
|
||||||
#pragma intvect DefaultIRQHandler 52 /* PPG18 */
|
#pragma intvect DefaultIRQHandler 52 /* PPG18 */
|
||||||
#pragma intvect DefaultIRQHandler 53 /* PPG19 */
|
#pragma intvect DefaultIRQHandler 53 /* PPG19 */
|
||||||
#pragma intvect DefaultIRQHandler 54 /* RLT0 */
|
#pragma intvect prvRLT0_TICKISR 54 /* RLT0 */
|
||||||
#pragma intvect DefaultIRQHandler 55 /* RLT1 */
|
#pragma intvect DefaultIRQHandler 55 /* RLT1 */
|
||||||
#pragma intvect DefaultIRQHandler 56 /* RLT2 */
|
#pragma intvect DefaultIRQHandler 56 /* RLT2 */
|
||||||
#pragma intvect DefaultIRQHandler 57 /* RLT3 */
|
#pragma intvect DefaultIRQHandler 57 /* RLT3 */
|
||||||
|
@ -126,17 +134,17 @@ __interrupt void DefaultIRQHandler (void);
|
||||||
#pragma intvect DefaultIRQHandler 92 /* LIN-UART 8 TX */
|
#pragma intvect DefaultIRQHandler 92 /* LIN-UART 8 TX */
|
||||||
#pragma intvect DefaultIRQHandler 93 /* MAIN FLASH IRQ */
|
#pragma intvect DefaultIRQHandler 93 /* MAIN FLASH IRQ */
|
||||||
|
|
||||||
|
#pragma intvect vPortYield 122 /* INT #122 */
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------
|
/*---------------------------------------------------------------------------
|
||||||
DefaultIRQHandler()
|
DefaultIRQHandler()
|
||||||
This function is a placeholder for all vector definitions. Either use
|
This function is a placeholder for all vector definitions. Either use
|
||||||
your own placeholder or add necessary code here.
|
your own placeholder or add necessary code here.
|
||||||
-----------------------------------------------------------------------------*/
|
-----------------------------------------------------------------------------*/
|
||||||
|
__interrupt void DefaultIRQHandler( void )
|
||||||
__interrupt
|
|
||||||
void DefaultIRQHandler (void)
|
|
||||||
{
|
{
|
||||||
__DI(); /* disable interrupts */
|
__DI(); /* disable interrupts */
|
||||||
while(1)
|
while( 1 )
|
||||||
{
|
{
|
||||||
__wait_nop(); /* halt system */
|
__wait_nop(); /* halt system */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue