mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -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 configTICK_RATE_HZ ( (portTickType) 1000 )
|
||||
#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 configUSE_16_BIT_TICKS 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\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\DiceTask.obj"
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
-Xals
|
||||
-Xalr
|
||||
-na
|
||||
-NCI0302LIB
|
||||
-w 2
|
||||
-cwno
|
||||
-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\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\DiceTask.obj"
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ PrjInfo-0=Debug
|
|||
Active=Debug
|
||||
|
||||
[MEMBER]
|
||||
F0=14
|
||||
F0=15
|
||||
F1=0 f Include Files
|
||||
F2=0 f FreeRTOS Source
|
||||
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
|
||||
F9=0 c ..\..\Source\tasks.c
|
||||
F10=0 f Demo Source
|
||||
F11=0 c main.c
|
||||
F12=0 a mb96356rs.asm
|
||||
F13=0 a START.ASM
|
||||
F14=0 c vectors.c
|
||||
F11=0 c DiceTask.c
|
||||
F12=0 c main.c
|
||||
F13=0 a mb96356rs.asm
|
||||
F14=0 a START.ASM
|
||||
F15=0 c vectors.c
|
||||
|
||||
[OPTIONFILE]
|
||||
FILE=options.dat
|
||||
|
@ -48,12 +49,22 @@ LST=LST\
|
|||
OPT=OPT\
|
||||
|
||||
[MEMBER-Debug]
|
||||
F0=12
|
||||
F0=13
|
||||
F1=0 m 1 ABS\RTOSDemo.abs
|
||||
F2=1 c 1 vectors.c
|
||||
F2=2 c 1 vectors.c
|
||||
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-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
|
||||
F5=0 a 1 START.ASM
|
||||
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-9=- ..\..\Source\Include\list.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]
|
||||
kernel=0
|
||||
|
|
|
@ -18,9 +18,5 @@ AutoLoad=1
|
|||
WSP=C:\E\Dev\FreeRTOS\WorkingCopy3\Demo\MB96350_Softune_Dice_Kit\
|
||||
|
||||
[EditState]
|
||||
STATE-1=..\..\Source\portable\Softune\MB96340\portmacro.h:54
|
||||
STATE-2=..\..\source\portable\softune\mb96340\port.c:52
|
||||
STATE-3=START.ASM:1
|
||||
STATE-4=main.c:202
|
||||
Count=4
|
||||
Count=0
|
||||
|
||||
|
|
|
@ -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 */
|
||||
/* ELIGIBILITY FOR ANY PURPOSES. */
|
||||
/* (C) Fujitsu Microelectronics Europe GmbH */
|
||||
/*---------------------------------------------------------------------------
|
||||
MAIN.C
|
||||
- description
|
||||
- See README.TXT for project description and disclaimer.
|
||||
/*
|
||||
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.
|
||||
|
||||
#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
|
||||
#define DICE_MAX 6
|
||||
#define DICERUN_MIN 600000L
|
||||
#define DICERUN_MAX 1200000L
|
||||
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
|
||||
|
||||
const char DICE7SEG1[11]={0x48, 0xeb, 0x8c, 0x89, 0x2b, 0x19, 0x18, 0xcb, 0x08, 0x09, 0xf7};
|
||||
const char DICE7SEG2[11]={0xa0, 0xf3, 0xc4, 0xc1, 0x93, 0x89, 0x88, 0xe3, 0x80, 0x81, 0x7f};
|
||||
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.
|
||||
|
||||
unsigned char temp;
|
||||
unsigned char dice1, dice2;
|
||||
unsigned long dice1run, dice2run;
|
||||
unsigned long dice1state, dice2state;
|
||||
unsigned long dice1delay, dice2delay;
|
||||
unsigned long dice1delayrld, dice2delayrld;
|
||||
***************************************************************************
|
||||
***************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
***************************************************************************
|
||||
***************************************************************************
|
||||
|
||||
/*===========================================================================*/
|
||||
/*====== MAIN ===============================================================*/
|
||||
/*===========================================================================*/
|
||||
Please ensure to read the configuration and relevant port sections of the
|
||||
online documentation.
|
||||
|
||||
void main(void)
|
||||
{
|
||||
InitIrqLevels();
|
||||
__set_il(7); // allow all levels
|
||||
__EI(); // globally enable interrupts
|
||||
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||
contact details.
|
||||
|
||||
// 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
|
||||
PDR00 = 0x00;
|
||||
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
|
||||
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||
licensing and training services.
|
||||
*/
|
||||
|
||||
PIER02 = 0x00; // All inputs are disabled on this port
|
||||
PDR02 = 0x00;
|
||||
DDR02 = 0xff;
|
||||
/* Kernel includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "Task.h"
|
||||
|
||||
PIER03 = 0x00; // All inputs are disabled on this port
|
||||
PDR03 = 0xff;
|
||||
DDR03 = 0xff; // Set Port3 as output (7Segment Display)
|
||||
/* Demo includes. */
|
||||
#include "DiceTask.h"
|
||||
|
||||
PIER04 = 0x04; // Enable P04_2/RX as input
|
||||
PDR04 = 0x08; // CAN TX = 1
|
||||
DDR04 = 0xfb; // CAN RX = input
|
||||
static void prvSetupHardware( void );
|
||||
|
||||
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
|
||||
PDR06 = 0x00;
|
||||
DDR06 = 0xff;
|
||||
void main( void )
|
||||
{
|
||||
prvSetupHardware();
|
||||
|
||||
while (1)
|
||||
{
|
||||
// DICE 1
|
||||
xTaskCreate( vDiceTask, ( signed char * ) "Dice", configMINIMAL_STACK_SIZE, ( void * ) 0, tskIDLE_PRIORITY, NULL );
|
||||
|
||||
switch (dice1state)
|
||||
{
|
||||
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)
|
||||
vTaskStartScheduler();
|
||||
|
||||
while( 1 );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
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
|
||||
-Xalr
|
||||
-na
|
||||
-NCI0302LIB
|
||||
-w 2
|
||||
-Xdof
|
||||
$other
|
||||
-Xset_rora
|
||||
$time
|
||||
1232226688
|
||||
1233316909
|
||||
$end
|
||||
$3
|
||||
-dt s,d,r,a
|
||||
|
@ -69,7 +70,7 @@ $3
|
|||
-Xdof
|
||||
$other
|
||||
$time
|
||||
1232226688
|
||||
1233316440
|
||||
$end
|
||||
$4
|
||||
-Xdof
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#include "mb96356rs.h"
|
||||
#include "FreeRTOSConfig.h"
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
InitIrqLevels()
|
||||
|
@ -33,6 +34,8 @@ void InitIrqLevels(void)
|
|||
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-
|
||||
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
|
||||
|
@ -53,7 +59,9 @@ __interrupt void DefaultIRQHandler (void);
|
|||
-----------------------------------------------------------------------------*/
|
||||
|
||||
#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 14 /* Main 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 52 /* PPG18 */
|
||||
#pragma intvect DefaultIRQHandler 53 /* PPG19 */
|
||||
#pragma intvect DefaultIRQHandler 54 /* RLT0 */
|
||||
#pragma intvect prvRLT0_TICKISR 54 /* RLT0 */
|
||||
#pragma intvect DefaultIRQHandler 55 /* RLT1 */
|
||||
#pragma intvect DefaultIRQHandler 56 /* RLT2 */
|
||||
#pragma intvect DefaultIRQHandler 57 /* RLT3 */
|
||||
|
@ -126,17 +134,17 @@ __interrupt void DefaultIRQHandler (void);
|
|||
#pragma intvect DefaultIRQHandler 92 /* LIN-UART 8 TX */
|
||||
#pragma intvect DefaultIRQHandler 93 /* MAIN FLASH IRQ */
|
||||
|
||||
#pragma intvect vPortYield 122 /* INT #122 */
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
DefaultIRQHandler()
|
||||
This function is a placeholder for all vector definitions. Either use
|
||||
your own placeholder or add necessary code here.
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
__interrupt
|
||||
void DefaultIRQHandler (void)
|
||||
__interrupt void DefaultIRQHandler( void )
|
||||
{
|
||||
__DI(); /* disable interrupts */
|
||||
while(1)
|
||||
while( 1 )
|
||||
{
|
||||
__wait_nop(); /* halt system */
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue