Skip to content

Commit

Permalink
merge default into stable for release v1.03
Browse files Browse the repository at this point in the history
  • Loading branch information
dimonomid committed Oct 20, 2014
2 parents d7dd070 + 4a94d51 commit 4b71d65
Show file tree
Hide file tree
Showing 75 changed files with 4,688 additions and 1,105 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<logicalFolder name="SourceFiles"
displayName="Source Files"
projectFiles="true">
<itemPath>../../../../src/arch/pic32/tn_arch_pic32_int_vec1.S</itemPath>
<itemPath>../src/tn_pic32_example_basic.c</itemPath>
<itemPath>../../../../../src/arch/pic32/tn_arch_pic32_int_vec1.S</itemPath>
<itemPath>../tn_pic32_example_basic.c</itemPath>
</logicalFolder>
<logicalFolder name="ExternalFiles"
displayName="Important Files"
Expand All @@ -22,8 +22,9 @@
</logicalFolder>
</logicalFolder>
<sourceRootList>
<Elem>../src</Elem>
<Elem>../../../../src/arch/pic32</Elem>
<Elem>../../../../../src/arch/pic32</Elem>
<Elem>..</Elem>
</sourceRootList>
<projectmakefile>Makefile</projectmakefile>
<confs>
Expand All @@ -42,12 +43,12 @@
<linkerTool>
<linkerLibItems>
<linkerLibProjectItem>
<makeArtifact PL="../../../../src/arch/pic32/tneokernel.X"
<makeArtifact PL="../../../../../src/arch/pic32/tneokernel.X"
CT="3"
CN="default"
AC="true"
BL="true"
WD="../../../../src/arch/pic32/tneokernel.X"
WD="../../../../../src/arch/pic32/tneokernel.X"
BC="${MAKE} -f Makefile CONF=default"
DBC="${MAKE} -f Makefile CONF=default TYPE_IMAGE=DEBUG_RUN"
CC="rm -rf &quot;build/default&quot; &quot;dist/default&quot;"
Expand Down Expand Up @@ -82,7 +83,7 @@
<property key="enable-symbols" value="true"/>
<property key="enable-unroll-loops" value="false"/>
<property key="exclude-floating-point" value="false"/>
<property key="extra-include-directories" value="../../../../src"/>
<property key="extra-include-directories" value="../../../../../src"/>
<property key="generate-16-bit-code" value="false"/>
<property key="generate-micro-compressed-code" value="false"/>
<property key="isolate-each-function" value="false"/>
Expand Down Expand Up @@ -182,7 +183,7 @@
<property key="save-temps" value="false"/>
<property key="wpo-lto" value="false"/>
</C32Global>
<PICkit3PlatformTool>
<ICD3PlatformTool>
<property key="ADC 1" value="true"/>
<property key="AutoSelectMemRanges" value="auto"/>
<property key="CHANGE NOTICE" value="true"/>
Expand Down Expand Up @@ -216,10 +217,10 @@
<property key="ToolFirmwareOption.UseLatestFirmware" value="true"/>
<property key="UART1" value="true"/>
<property key="UART2" value="true"/>
<property key="firmware.download.all" value="false"/>
<property key="debugoptions.useswbreakpoints" value="false"/>
<property key="hwtoolclock.frcindebug" value="false"/>
<property key="memories.aux" value="false"/>
<property key="memories.bootflash" value="true"/>
<property key="memories.bootflash" value="false"/>
<property key="memories.configurationmemory" value="true"/>
<property key="memories.eeprom" value="true"/>
<property key="memories.flashdata" value="true"/>
Expand All @@ -228,10 +229,8 @@
<property key="memories.programmemory.end" value="0x1d07ffff"/>
<property key="memories.programmemory.start" value="0x1d000000"/>
<property key="poweroptions.powerenable" value="false"/>
<property key="programmertogo.imagename" value=""/>
<property key="programoptions.donoteraseauxmem" value="false"/>
<property key="programoptions.eraseb4program" value="true"/>
<property key="programoptions.pgmspeed" value="2"/>
<property key="programoptions.preserveeeprom" value="false"/>
<property key="programoptions.preserveprogramrange" value="false"/>
<property key="programoptions.preserveprogramrange.end" value="0x1d07ffff"/>
Expand All @@ -241,7 +240,7 @@
<property key="programoptions.usehighvoltageonmclr" value="false"/>
<property key="programoptions.uselvpprogramming" value="false"/>
<property key="voltagevalue" value="3.25"/>
</PICkit3PlatformTool>
</ICD3PlatformTool>
</conf>
</confs>
</configurationDescriptor>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<asminc-extensions/>
<sourceEncoding>UTF-8</sourceEncoding>
<make-dep-projects>
<make-dep-project>../../../../src/arch/pic32/tneokernel.X</make-dep-project>
<make-dep-project>../../../../../src/arch/pic32/tneokernel.X</make-dep-project>
</make-dep-projects>
</data>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@
// and for interrupts are the requirement of the kernel;
// others are application-dependent.
//
// We use convenience macro TN_TASK_STACK_DEF() for that.
// We use convenience macro TN_STACK_ARR_DEF() for that.

TN_TASK_STACK_DEF(idle_task_stack, IDLE_TASK_STACK_SIZE);
TN_TASK_STACK_DEF(interrupt_stack, INTERRUPT_STACK_SIZE);
TN_STACK_ARR_DEF(idle_task_stack, IDLE_TASK_STACK_SIZE);
TN_STACK_ARR_DEF(interrupt_stack, INTERRUPT_STACK_SIZE);

TN_TASK_STACK_DEF(task_a_stack, TASK_A_STK_SIZE);
TN_TASK_STACK_DEF(task_b_stack, TASK_B_STK_SIZE);
TN_TASK_STACK_DEF(task_c_stack, TASK_C_STK_SIZE);
TN_STACK_ARR_DEF(task_a_stack, TASK_A_STK_SIZE);
TN_STACK_ARR_DEF(task_b_stack, TASK_B_STK_SIZE);
TN_STACK_ARR_DEF(task_c_stack, TASK_C_STK_SIZE);



Expand Down Expand Up @@ -202,10 +202,6 @@ void hw_init(void)
INTClearFlag(INT_CS0);
INTEnable(INT_CS0, INT_ENABLED);

//-- configure LED port pins
mPORTESetPinsDigitalOut(BIT_0 | BIT_1 | BIT_2);
mPORTEClearBits(BIT_0 | BIT_1 | BIT_2);

//-- enable multi-vectored interrupt mode
INTConfigureSystem(INT_SYSTEM_CONFIG_MULT_VECTOR);
}
Expand All @@ -215,6 +211,10 @@ void hw_init(void)
*/
void appl_init(void)
{
//-- configure LED port pins
mPORTESetPinsDigitalOut(BIT_0 | BIT_1 | BIT_2);
mPORTEClearBits(BIT_0 | BIT_1 | BIT_2);

//-- initialize various on-board peripherals, such as
// flash memory, displays, etc.
// (in this sample project there's nothing to init)
Expand Down
41 changes: 41 additions & 0 deletions examples/common/arch/pic32/example_arch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*******************************************************************************
* Description: TODO
*
******************************************************************************/

#ifndef _EXAMPLE_ARCH_H
#define _EXAMPLE_ARCH_H

/*******************************************************************************
* INCLUDED FILES
******************************************************************************/

/*******************************************************************************
* PUBLIC TYPES
******************************************************************************/

/*******************************************************************************
* GLOBAL VARIABLES
******************************************************************************/

/*******************************************************************************
* DEFINITIONS
******************************************************************************/

//-- instruction that causes debugger to halt
#define SOFTWARE_BREAK() __asm__ volatile ("sdbbp 0")


/*******************************************************************************
* PUBLIC FUNCTION PROTOTYPES
******************************************************************************/


#endif // _EXAMPLE_ARCH_H


/*******************************************************************************
* end of file
******************************************************************************/


198 changes: 198 additions & 0 deletions examples/common/arch/pic32/pic32_arch.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
/**
* TNeoKernel PIC32 basic example
*/

/*******************************************************************************
* INCLUDED FILES
******************************************************************************/

#include <xc.h>
#include <plib.h>
#include <stdint.h>
#include "tn.h"

#include "example_arch.h"



/*******************************************************************************
* PIC32 HARDWARE CONFIGURATION
******************************************************************************/

#pragma config FNOSC = PRIPLL // Oscillator Selection
#pragma config FPLLIDIV = DIV_4 // PLL Input Divider (PIC32 Starter Kit: use divide by 2 only)
#pragma config FPLLMUL = MUL_20 // PLL Multiplier
#pragma config FPLLODIV = DIV_1 // PLL Output Divider
#pragma config FPBDIV = DIV_2 // Peripheral Clock divisor
#pragma config FWDTEN = OFF // Watchdog Timer
#pragma config WDTPS = PS1 // Watchdog Timer Postscale
#pragma config FCKSM = CSDCMD // Clock Switching & Fail Safe Clock Monitor
#pragma config OSCIOFNC = OFF // CLKO Enable
#pragma config POSCMOD = HS // Primary Oscillator
#pragma config IESO = OFF // Internal/External Switch-over
#pragma config FSOSCEN = OFF // Secondary Oscillator Enable
#pragma config CP = OFF // Code Protect
#pragma config BWP = OFF // Boot Flash Write Protect
#pragma config PWP = OFF // Program Flash Write Protect
#pragma config ICESEL = ICS_PGx2 // ICE/ICD Comm Channel Select
#pragma config DEBUG = OFF // Debugger Disabled for Starter Kit




/*******************************************************************************
* MACROS
******************************************************************************/

//-- system frequency
#define SYS_FREQ 80000000UL

//-- peripheral bus frequency
#define PB_FREQ 40000000UL

//-- kernel ticks (system timer) frequency
#define SYS_TMR_FREQ 1000

//-- system timer prescaler
#define SYS_TMR_PRESCALER T5_PS_1_8
#define SYS_TMR_PRESCALER_VALUE 8

//-- system timer period (auto-calculated)
#define SYS_TMR_PERIOD \
(PB_FREQ / SYS_TMR_PRESCALER_VALUE / SYS_TMR_FREQ)




//-- idle task stack size, in words
#define IDLE_TASK_STACK_SIZE (TN_MIN_STACK_SIZE + 16)

//-- interrupt stack size, in words
#define INTERRUPT_STACK_SIZE (TN_MIN_STACK_SIZE + 64)



/*******************************************************************************
* EXTERN FUNCTION PROTOTYPE
******************************************************************************/

//-- defined by particular example: create first application task(s)
extern void init_task_create(void);



/*******************************************************************************
* DATA
******************************************************************************/

//-- Allocate arrays for stacks: stack for idle task
// and for interrupts are the requirement of the kernel;
// others are application-dependent.
//
// We use convenience macro TN_STACK_ARR_DEF() for that.

TN_STACK_ARR_DEF(idle_task_stack, IDLE_TASK_STACK_SIZE);
TN_STACK_ARR_DEF(interrupt_stack, INTERRUPT_STACK_SIZE);



/*******************************************************************************
* ISRs
******************************************************************************/

/**
* system timer ISR
*/
tn_soft_isr(_TIMER_5_VECTOR)
{
INTClearFlag(INT_T5);
tn_tick_int_processing();
}



/*******************************************************************************
* FUNCTIONS
******************************************************************************/

/**
* Hardware init: called from main() with interrupts disabled
*/
void hw_init(void)
{
SYSTEMConfig(SYS_FREQ, SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE);

//turn off ADC function for all pins
AD1PCFG = 0xffffffff;

//-- enable timer5 interrupt
OpenTimer5((0
| T5_ON
| T5_IDLE_STOP
| SYS_TMR_PRESCALER
| T5_SOURCE_INT
),
(SYS_TMR_PERIOD - 1)
);

//-- set timer5 interrupt priority to 2, enable it
INTSetVectorPriority(INT_TIMER_5_VECTOR, INT_PRIORITY_LEVEL_2);
INTSetVectorSubPriority(INT_TIMER_5_VECTOR, INT_SUB_PRIORITY_LEVEL_0);
INTClearFlag(INT_T5);
INTEnable(INT_T5, INT_ENABLED);

//-- TNeoKernel PIC32 requirement:
// set up the software interrupt 0 with a priority of 1, subpriority 0
//
// NOTE: the ISR is declared in kernel-provided file
// tn_arch_pic32_int_vec1.S, which should be included in the application
// project itself, in order to dispatch vector correctly.
INTSetVectorPriority(INT_CORE_SOFTWARE_0_VECTOR, INT_PRIORITY_LEVEL_1);
INTSetVectorSubPriority(INT_CORE_SOFTWARE_0_VECTOR, INT_SUB_PRIORITY_LEVEL_0);
INTClearFlag(INT_CS0);
INTEnable(INT_CS0, INT_ENABLED);

//-- enable multi-vectored interrupt mode
INTConfigureSystem(INT_SYSTEM_CONFIG_MULT_VECTOR);
}

//-- idle callback that is called periodically from idle task
void idle_task_callback (void)
{
}

int32_t main(void)
{
#ifndef PIC32_STARTER_KIT
/*The JTAG is on by default on POR. A PIC32 Starter Kit uses the JTAG, but
for other debug tool use, like ICD 3 and Real ICE, the JTAG should be off
to free up the JTAG I/O */
DDPCONbits.JTAGEN = 0;
#endif

//-- unconditionally disable interrupts
tn_arch_int_dis();

//-- init hardware
hw_init();

//-- call to tn_sys_start() never returns
tn_sys_start(
idle_task_stack,
IDLE_TASK_STACK_SIZE,
interrupt_stack,
INTERRUPT_STACK_SIZE,
init_task_create,
idle_task_callback
);

//-- unreachable
return 1;
}

void __attribute__((naked, nomips16, noreturn)) _general_exception_handler(void)
{
SOFTWARE_BREAK();
for (;;) ;
}

Loading

0 comments on commit 4b71d65

Please sign in to comment.