SW0, SW1 button int test.
Revision 1:a88865265000, committed 2015-01-08
- Comitter:
- mzta
- Date:
- Thu Jan 08 01:18:02 2015 +0000
- Parent:
- 0:044197641ae8
- Commit message:
- Changed to use the cmsis GIC API in priority setting.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 044197641ae8 -r a88865265000 main.cpp --- a/main.cpp Wed Jan 07 17:58:43 2015 +0000 +++ b/main.cpp Thu Jan 08 01:18:02 2015 +0000 @@ -24,66 +24,15 @@ bled = 1; } -int32_t R_INTC_SetPriority(uint16_t int_id, uint8_t priority); - int main() { rled = 1; bled = 1; - R_INTC_SetPriority(BTN0_IRQ, 1); + + GIC_SetPriority(BTN1_IRQ, 10); // Pri 10 に落とす button0.fall(&button0_int_handler); button1.fall(&button1_int_handler); + while(1) { wait(1); } } - -/** - * http://japan.renesas.com/req/sample_code.do?event=searchProducts&%20expandedProductsId=1&productsId=186374 - */ -#include "r_typedefs.h" -#include "dev_drv.h" /* Device Driver common header */ -//#include "devdrv_intc.h" /* INTC Driver Header */ -#include "iodefine.h" -#define INTC_ID_TOTAL (587) -/****************************************************************************** -* Function Name: R_INTC_SetPriority -* Description : Sets the priority level of the ID specified by the int_id to -* : the priority level specified by the priority. -* Arguments : uint16_t int_id : Interrupt ID -* : uint8_t priority : Interrupt priority level (0 to 31) -* Return Value : DEVDRV_SUCCESS : Success of INTC interrupt priority level setting -* : DEVDRV_ERROR : Failure of INTC interrupt priority level setting -******************************************************************************/ -int32_t R_INTC_SetPriority(uint16_t int_id, uint8_t priority) -{ - uint32_t icdipr; - uint32_t mask; - volatile uint32_t * addr; - - /* ==== Argument check ==== */ - if ((int_id >= INTC_ID_TOTAL) || priority >= 32) - { - return DEVDRV_ERROR; /* Argument error */ - } - - priority = priority << 3; /* Priority[7:3] of ICDIPRn is valid bit */ - - /* ICDIPRn has 4 sources in the 32 bits */ - /* The n can be calculated by int_id / 4 */ - /* The bit field width is 8 bits */ - /* The target bit can be calculated by (int_id % 4) * 8 */ - addr = (volatile uint32_t *)&INTC.ICDIPR0; - - icdipr = *(addr + (int_id / 4)); /* Read ICDIPRn */ - - mask = (uint32_t)0x000000FFuL; /* ---- Mask ---- */ - mask = mask << ((int_id % 4) * 8); /* Shift to target bit */ - icdipr &= ~mask; /* Clear priority */ - mask = (uint32_t)priority; /* ---- Priority ---- */ - mask = mask << ((int_id % 4) * 8); /* Shift to target bit */ - icdipr |= mask; /* Set priority */ - - *(addr + (int_id / 4)) = icdipr; /* Write ICDIPRn */ - - return DEVDRV_SUCCESS; -}