Advertisement
Guest User

pic32_ethernet_starter_kit.diff

a guest
Jan 3rd, 2014
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 26.44 KB | None | 0 0
  1. Index: pkg/board/microchip_esk/src/ee_board.c
  2. ===================================================================
  3. --- pkg/board/microchip_esk/src/ee_board.c  (revision 0)
  4. +++ pkg/board/microchip_esk/src/ee_board.c  (revision 0)
  5. @@ -0,0 +1,77 @@
  6. +/* ###*B*###
  7. + * ERIKA Enterprise - a tiny RTOS for small microcontrollers
  8. + *
  9. + * Copyright (C) 2002-2008  Evidence Srl
  10. + *
  11. + * This file is part of ERIKA Enterprise.
  12. + *
  13. + * ERIKA Enterprise is free software; you can redistribute it
  14. + * and/or modify it under the terms of the GNU General Public License
  15. + * version 2 as published by the Free Software Foundation,
  16. + * (with a special exception described below).
  17. + *
  18. + * Linking this code statically or dynamically with other modules is
  19. + * making a combined work based on this code.  Thus, the terms and
  20. + * conditions of the GNU General Public License cover the whole
  21. + * combination.
  22. + *
  23. + * As a special exception, the copyright holders of this library give you
  24. + * permission to link this code with independent modules to produce an
  25. + * executable, regardless of the license terms of these independent
  26. + * modules, and to copy and distribute the resulting executable under
  27. + * terms of your choice, provided that you also meet, for each linked
  28. + * independent module, the terms and conditions of the license of that
  29. + * module.  An independent module is a module which is not derived from
  30. + * or based on this library.  If you modify this code, you may extend
  31. + * this exception to your version of the code, but you are not
  32. + * obligated to do so.  If you do not wish to do so, delete this
  33. + * exception statement from your version.
  34. + *
  35. + * ERIKA Enterprise is distributed in the hope that it will be
  36. + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  37. + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  38. + * GNU General Public License version 2 for more details.
  39. + *
  40. + * You should have received a copy of the GNU General Public License
  41. + * version 2 along with ERIKA Enterprise; if not, write to the
  42. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  43. + * Boston, MA 02110-1301 USA.
  44. + * ###*E*### */
  45. +
  46. +/*
  47. + * ## Author: 2014 Angelo Compagnucci <angelo.compagnucci@gmail.com>
  48. + *
  49. + */
  50. +
  51. +#include "ee_internal.h"
  52. +#include "board/microchip_esk/inc/ee_board.h"
  53. +
  54. +#if defined __PIC32__
  55. +#include "cpu/pic32/inc/ee_irqstub.h"
  56. +#include "mcu/microchip_pic32/inc/ee_mcu.h"
  57. +#else
  58. +#error "Unsupported pic on esk board"
  59. +#endif
  60. +
  61. +
  62. +/* ************************************************************************* */
  63. +/* Buttons */
  64. +/* ************************************************************************* */
  65. +
  66. +#ifdef __USE_BUTTONS__
  67. +
  68. +void (*EE_button_callback)(void);
  69. +EE_UINT8 EE_button_mask;
  70. +
  71. +ISR2(EE_ESK_IRQ_HANDLER_NAME)
  72. +{
  73. +   // Execute callback function
  74. +   if (EE_button_callback != NULL) {
  75. +       EE_button_callback();
  76. +   }
  77. +      
  78. +   /* reset CN interrupt flag */
  79. +   IFS1bits.CNIF = 0;          
  80. +}
  81. +
  82. +#endif
  83. Index: pkg/board/microchip_esk/inc/ee_internal.h
  84. ===================================================================
  85. --- pkg/board/microchip_esk/inc/ee_internal.h   (revision 0)
  86. +++ pkg/board/microchip_esk/inc/ee_internal.h   (revision 0)
  87. @@ -0,0 +1,46 @@
  88. +/* ###*B*###
  89. + * ERIKA Enterprise - a tiny RTOS for small microcontrollers
  90. + *
  91. + * Copyright (C) 2002-2008  Evidence Srl
  92. + *
  93. + * This file is part of ERIKA Enterprise.
  94. + *
  95. + * ERIKA Enterprise is free software; you can redistribute it
  96. + * and/or modify it under the terms of the GNU General Public License
  97. + * version 2 as published by the Free Software Foundation,
  98. + * (with a special exception described below).
  99. + *
  100. + * Linking this code statically or dynamically with other modules is
  101. + * making a combined work based on this code.  Thus, the terms and
  102. + * conditions of the GNU General Public License cover the whole
  103. + * combination.
  104. + *
  105. + * As a special exception, the copyright holders of this library give you
  106. + * permission to link this code with independent modules to produce an
  107. + * executable, regardless of the license terms of these independent
  108. + * modules, and to copy and distribute the resulting executable under
  109. + * terms of your choice, provided that you also meet, for each linked
  110. + * independent module, the terms and conditions of the license of that
  111. + * module.  An independent module is a module which is not derived from
  112. + * or based on this library.  If you modify this code, you may extend
  113. + * this exception to your version of the code, but you are not
  114. + * obligated to do so.  If you do not wish to do so, delete this
  115. + * exception statement from your version.
  116. + *
  117. + * ERIKA Enterprise is distributed in the hope that it will be
  118. + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  119. + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  120. + * GNU General Public License version 2 for more details.
  121. + *
  122. + * You should have received a copy of the GNU General Public License
  123. + * version 2 along with ERIKA Enterprise; if not, write to the
  124. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  125. + * Boston, MA 02110-1301 USA.
  126. + * ###*E*### */
  127. +
  128. +/*
  129. + * Author: 2014 Angelo Compagnucci <angelo.compagnucci@gmail.com>
  130. + *
  131. + */
  132. +
  133. +#include "board/microchip_esk/inc/ee_board.h"
  134. Index: pkg/board/microchip_esk/inc/ee_esk_pic32_hal.h
  135. ===================================================================
  136. --- pkg/board/microchip_esk/inc/ee_esk_pic32_hal.h  (revision 0)
  137. +++ pkg/board/microchip_esk/inc/ee_esk_pic32_hal.h  (revision 0)
  138. @@ -0,0 +1,69 @@
  139. +/* ###*B*###
  140. + * ERIKA Enterprise - a tiny RTOS for small microcontrollers
  141. + *
  142. + * Copyright (C) 2002-2008  Evidence Srl
  143. + *
  144. + * This file is part of ERIKA Enterprise.
  145. + *
  146. + * ERIKA Enterprise is free software; you can redistribute it
  147. + * and/or modify it under the terms of the GNU General Public License
  148. + * version 2 as published by the Free Software Foundation,
  149. + * (with a special exception described below).
  150. + *
  151. + * Linking this code statically or dynamically with other modules is
  152. + * making a combined work based on this code.  Thus, the terms and
  153. + * conditions of the GNU General Public License cover the whole
  154. + * combination.
  155. + *
  156. + * As a special exception, the copyright holders of this library give you
  157. + * permission to link this code with independent modules to produce an
  158. + * executable, regardless of the license terms of these independent
  159. + * modules, and to copy and distribute the resulting executable under
  160. + * terms of your choice, provided that you also meet, for each linked
  161. + * independent module, the terms and conditions of the license of that
  162. + * module.  An independent module is a module which is not derived from
  163. + * or based on this library.  If you modify this code, you may extend
  164. + * this exception to your version of the code, but you are not
  165. + * obligated to do so.  If you do not wish to do so, delete this
  166. + * exception statement from your version.
  167. + *
  168. + * ERIKA Enterprise is distributed in the hope that it will be
  169. + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  170. + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  171. + * GNU General Public License version 2 for more details.
  172. + *
  173. + * You should have received a copy of the GNU General Public License
  174. + * version 2 along with ERIKA Enterprise; if not, write to the
  175. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  176. + * Boston, MA 02110-1301 USA.
  177. + * ###*E*### */
  178. +
  179. +/*
  180. + * Author: 2014 Angelo Compagnucci <angelo.compagnucci@gmail.com>
  181. + *
  182. + */
  183. +
  184. +
  185. +#include "mcu/microchip_pic32/inc/ee_mcu.h"
  186. +
  187. +
  188. +/* Configure button pins for digital inputs */
  189. +#define EE_esk_AD_Confict_Solve() AD1PCFG = 0x00099000;
  190. +
  191. +/* enabling interrupt notifications on S3/RD6, S4/RD13, and S6/RD7 */
  192. +/* the interrupt notification cannot be enabled on S5/RA7 */
  193. +#define EE_esk_cn_1_int_en() CNENbits.CNEN15 = 1; CNPUEbits.CNPUE15 = 1 /* S0/RD6  */
  194. +#define EE_esk_cn_2_int_en() CNENbits.CNEN16 = 1; CNPUEbits.CNPUE16 = 1    /* S1/RD7  */
  195. +#define EE_esk_cn_4_int_en() CNENbits.CNEN19 = 1; CNPUEbits.CNPUE19 = 1 /* S2/RD13 */
  196. +
  197. +/* Enable Change Notice module */
  198. +#define EE_esk_cn_pri() CNCON = 0x8000
  199. +
  200. +/* Set Interrupt priority level=5 and Subpriority level=3 */
  201. +#define EE_esk_cn_pri_lev() IPC6SET = 0x00170000;
  202. +
  203. +/* IRQ Handler */
  204. +#define EE_ESK_IRQ_HANDLER_NAME    _CHANGE_NOTICE_VECTOR
  205. +
  206. +/* Interrupt vector */
  207. +#define EE_ESK_INT_VECT    _ADC_VECTOR
  208. Index: pkg/board/microchip_esk/inc/ee_board.h
  209. ===================================================================
  210. --- pkg/board/microchip_esk/inc/ee_board.h  (revision 0)
  211. +++ pkg/board/microchip_esk/inc/ee_board.h  (revision 0)
  212. @@ -0,0 +1,149 @@
  213. +/* ###*B*###
  214. + * ERIKA Enterprise - a tiny RTOS for small microcontrollers
  215. + *
  216. + * Copyright (C) 2002-2008  Evidence Srl
  217. + *
  218. + * This file is part of ERIKA Enterprise.
  219. + *
  220. + * ERIKA Enterprise is free software; you can redistribute it
  221. + * and/or modify it under the terms of the GNU General Public License
  222. + * version 2 as published by the Free Software Foundation,
  223. + * (with a special exception described below).
  224. + *
  225. + * Linking this code statically or dynamically with other modules is
  226. + * making a combined work based on this code.  Thus, the terms and
  227. + * conditions of the GNU General Public License cover the whole
  228. + * combination.
  229. + *
  230. + * As a special exception, the copyright holders of this library give you
  231. + * permission to link this code with independent modules to produce an
  232. + * executable, regardless of the license terms of these independent
  233. + * modules, and to copy and distribute the resulting executable under
  234. + * terms of your choice, provided that you also meet, for each linked
  235. + * independent module, the terms and conditions of the license of that
  236. + * module.  An independent module is a module which is not derived from
  237. + * or based on this library.  If you modify this code, you may extend
  238. + * this exception to your version of the code, but you are not
  239. + * obligated to do so.  If you do not wish to do so, delete this
  240. + * exception statement from your version.
  241. + *
  242. + * ERIKA Enterprise is distributed in the hope that it will be
  243. + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  244. + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  245. + * GNU General Public License version 2 for more details.
  246. + *
  247. + * You should have received a copy of the GNU General Public License
  248. + * version 2 along with ERIKA Enterprise; if not, write to the
  249. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  250. + * Boston, MA 02110-1301 USA.
  251. + * ###*E*### */
  252. +
  253. +/*
  254. + * Author: 2014 Angelo Compagnucci <angelo.compagnucci@gmail.com>
  255. + *
  256. + */
  257. +
  258. +#ifndef __INCLUDE_MICROCHIP_esk_BOARD_H__
  259. +#define __INCLUDE_MICROCHIP_esk_BOARD_H__
  260. +
  261. +
  262. +#if defined __PIC32__
  263. +#include "board/microchip_esk/inc/ee_esk_pic32_hal.h"
  264. +#else
  265. +#error "Unsupported pic on esk board"
  266. +#endif
  267. +
  268. +
  269. +/* ************************************************************************* */
  270. +/* Buttons */
  271. +/* ************************************************************************* */
  272. +
  273. +#ifdef __USE_BUTTONS__
  274. +
  275. +extern void (*EE_button_callback)(void);
  276. +extern EE_UINT8 EE_button_mask;
  277. +
  278. +__INLINE__ void __ALWAYS_INLINE__ EE_buttons_init( void(*isr_callback)(void), EE_UINT8 mask ) {
  279. +   /* set BUTTON pins (S0/RD6-S1/RD7-S2/RD13) as inputs */
  280. +   TRISDbits.TRISD6  = 1;
  281. +   TRISDbits.TRISD7  = 1;
  282. +   TRISDbits.TRISD13 = 1;
  283. +
  284. +   /* Solve conflict againd AD module */
  285. +   EE_esk_AD_Confict_Solve();
  286. +
  287. +   /* Enable Interrupt */
  288. +   if (isr_callback != NULL) {
  289. +     /* Enable Change Notice module */
  290. +     EE_esk_cn_pri();
  291. +
  292. +     if (mask & 0x01)
  293. +       EE_esk_cn_1_int_en();   /* S0/RD6 */
  294. +     if (mask & 0x02)
  295. +       EE_esk_cn_2_int_en();   /* S1/RD7 */
  296. +     if (mask & 0x04)
  297. +       EE_esk_cn_4_int_en();   /* S2/RD13 */
  298. +
  299. +     /* Set interrupt priority Level and Sublevel */
  300. +     EE_esk_cn_pri_lev();
  301. +
  302. +     IFS1bits.CNIF = 1;
  303. +     IEC1bits.CNIE = 1;
  304. +   }
  305. +
  306. +   /* Save callback */
  307. +   EE_button_callback = isr_callback; 
  308. +}
  309. +
  310. +__INLINE__ EE_UINT8 __ALWAYS_INLINE__ EE_button_get_S1( void ) {
  311. +   if (PORTDbits.RD6)
  312. +       return 0;
  313. +   else
  314. +       return 1;
  315. +}
  316. +__INLINE__ EE_UINT8 __ALWAYS_INLINE__ EE_button_get_S2( void ) {
  317. +   if (PORTDbits.RD7)
  318. +       return 0;
  319. +   else
  320. +       return 1;
  321. +}
  322. +__INLINE__ EE_UINT8 __ALWAYS_INLINE__ EE_button_get_S3( void ) {
  323. +   if (PORTDbits.RD13)
  324. +       return 0;
  325. +   else
  326. +       return 1;
  327. +}
  328. +
  329. +#endif
  330. +
  331. +
  332. +/* ************************************************************************* */
  333. +/*  LEDs */
  334. +/* ************************************************************************* */
  335. +
  336. +#ifdef __USE_LEDS__
  337. +
  338. +__INLINE__ void __ALWAYS_INLINE__ EE_leds_init(void) {
  339. +  /* set LEDs (D0-D2) drive state low */
  340. +  LATD &= 0xFFF8;
  341. +  /* set LED pins (D0-D2) as outputs */
  342. +  TRISD &= 0xFFF8;
  343. +}
  344. +
  345. +__INLINE__ void __ALWAYS_INLINE__ EE_leds_on(void)   { LATD |= 0x0007; }
  346. +__INLINE__ void __ALWAYS_INLINE__ EE_leds_off(void)  { LATD &= 0xFFF8; }
  347. +
  348. +__INLINE__ void __ALWAYS_INLINE__ EE_leds( EE_UINT8 data )  { LATD &= 0xFFF8; LATD |= data; }
  349. +
  350. +__INLINE__ void __ALWAYS_INLINE__ EE_led_0_on(void)   { LATDbits.LATD0 = 1; }
  351. +__INLINE__ void __ALWAYS_INLINE__ EE_led_0_off(void)  { LATDbits.LATD0 = 0; }
  352. +__INLINE__ void __ALWAYS_INLINE__ EE_led_1_on(void)   { LATDbits.LATD1 = 1; }
  353. +__INLINE__ void __ALWAYS_INLINE__ EE_led_1_off(void)  { LATDbits.LATD1 = 0; }
  354. +__INLINE__ void __ALWAYS_INLINE__ EE_led_2_on(void)   { LATDbits.LATD2 = 1; }
  355. +__INLINE__ void __ALWAYS_INLINE__ EE_led_2_off(void)  { LATDbits.LATD2 = 0; }
  356. +
  357. +__INLINE__ EE_UINT8 __ALWAYS_INLINE__ EE_led_is_on(EE_UINT8 led)   { return PORTD & (1 << led); }
  358. +
  359. +#endif
  360. +
  361. +#endif
  362. Index: pkg/board/microchip_esk/cfg/cfg.mk
  363. ===================================================================
  364. --- pkg/board/microchip_esk/cfg/cfg.mk  (revision 0)
  365. +++ pkg/board/microchip_esk/cfg/cfg.mk  (revision 0)
  366. @@ -0,0 +1,50 @@
  367. +# ###*B*###
  368. +# ERIKA Enterprise - a tiny RTOS for small microcontrollers
  369. +#
  370. +# Copyright (C) 2002-2008  Evidence Srl
  371. +#
  372. +# This file is part of ERIKA Enterprise.
  373. +#
  374. +# ERIKA Enterprise is free software; you can redistribute it
  375. +# and/or modify it under the terms of the GNU General Public License
  376. +# version 2 as published by the Free Software Foundation,
  377. +# (with a special exception described below).
  378. +#
  379. +# Linking this code statically or dynamically with other modules is
  380. +# making a combined work based on this code.  Thus, the terms and
  381. +# conditions of the GNU General Public License cover the whole
  382. +# combination.
  383. +#
  384. +# As a special exception, the copyright holders of this library give you
  385. +# permission to link this code with independent modules to produce an
  386. +# executable, regardless of the license terms of these independent
  387. +# modules, and to copy and distribute the resulting executable under
  388. +# terms of your choice, provided that you also meet, for each linked
  389. +# independent module, the terms and conditions of the license of that
  390. +# module.  An independent module is a module which is not derived from
  391. +# or based on this library.  If you modify this code, you may extend
  392. +# this exception to your version of the code, but you are not
  393. +# obligated to do so.  If you do not wish to do so, delete this
  394. +# exception statement from your version.
  395. +#
  396. +# ERIKA Enterprise is distributed in the hope that it will be
  397. +# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  398. +# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  399. +# GNU General Public License version 2 for more details.
  400. +#
  401. +# You should have received a copy of the GNU General Public License
  402. +# version 2 along with ERIKA Enterprise; if not, write to the
  403. +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  404. +# Boston, MA 02110-1301 USA.
  405. +# ###*E*###
  406. +
  407. +## Author: 2014 Angelo Compagnucci <angelo.compagnucci@gmail.com>
  408. +
  409. +ifeq ($(call iseeopt, __MICROCHIP_ESK__), yes)
  410. +EE_SRCS += pkg/board/microchip_esk/src/ee_board.c
  411. +
  412. +ifeq ($(call iseeopt, __USE_BUTTONS__), yes)
  413. +OPT_LINK += -u__CNInterrupt
  414. +endif
  415. +
  416. +endif
  417. Index: pkg/ee_internal.h
  418. ===================================================================
  419. --- pkg/ee_internal.h   (revision 2913)
  420. +++ pkg/ee_internal.h   (working copy)
  421. @@ -283,6 +283,10 @@
  422.  #include "board/ee_miniflex/inc/ee_internal.h"
  423.  #endif
  424.  
  425. +#ifdef __MICROCHIP_ESK__
  426. +#include "board/microchip_esk/inc/ee_internal.h"
  427. +#endif
  428. +
  429.   /* MICO32 */
  430.  #ifdef __LM32__
  431.  #include "board/fpg-eye/inc/ee_internal.h"
  432. Index: pkg/ee.h
  433. ===================================================================
  434. --- pkg/ee.h    (revision 2913)
  435. +++ pkg/ee.h    (working copy)
  436. @@ -322,6 +322,10 @@
  437.  #include "board/ipermob_board_v2/inc/ee_board.h"
  438.  #endif
  439.  
  440. +#ifdef __MICROCHIP_ESK__
  441. +#include "board/microchip_esk/inc/ee_board.h"
  442. +#endif
  443. +
  444.   /* MICO32 */
  445.  #ifdef __FPG_EYE__
  446.  #include "board/fpg-eye/inc/ee_board.h"
  447. Index: examples/pic32/esk/pic32_esk_base/conf.oil
  448. ===================================================================
  449. --- examples/pic32/esk/pic32_esk_base/conf.oil  (revision 0)
  450. +++ examples/pic32/esk/pic32_esk_base/conf.oil  (revision 0)
  451. @@ -0,0 +1,107 @@
  452. +/* ###*B*###
  453. + * ERIKA Enterprise - a tiny RTOS for small microcontrollers
  454. + *
  455. + * Copyright (C) 2002-2008  Evidence Srl
  456. + *
  457. + * This file is part of ERIKA Enterprise.
  458. + *
  459. + * ERIKA Enterprise is free software; you can redistribute it
  460. + * and/or modify it under the terms of the GNU General Public License
  461. + * version 2 as published by the Free Software Foundation,
  462. + * (with a special exception described below).
  463. + *
  464. + * Linking this code statically or dynamically with other modules is
  465. + * making a combined work based on this code.  Thus, the terms and
  466. + * conditions of the GNU General Public License cover the whole
  467. + * combination.
  468. + *
  469. + * As a special exception, the copyright holders of this library give you
  470. + * permission to link this code with independent modules to produce an
  471. + * executable, regardless of the license terms of these independent
  472. + * modules, and to copy and distribute the resulting executable under
  473. + * terms of your choice, provided that you also meet, for each linked
  474. + * independent module, the terms and conditions of the license of that
  475. + * module.  An independent module is a module which is not derived from
  476. + * or based on this library.  If you modify this code, you may extend
  477. + * this exception to your version of the code, but you are not
  478. + * obligated to do so.  If you do not wish to do so, delete this
  479. + * exception statement from your version.
  480. + *
  481. + * ERIKA Enterprise is distributed in the hope that it will be
  482. + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  483. + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  484. + * GNU General Public License version 2 for more details.
  485. + *
  486. + * You should have received a copy of the GNU General Public License
  487. + * version 2 along with ERIKA Enterprise; if not, write to the
  488. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  489. + * Boston, MA 02110-1301 USA.
  490. + * ###*E*### */
  491. +
  492. +
  493. +CPU mySystem {
  494. +
  495. +   OS myOs {
  496. +       EE_OPT = "DEBUG";
  497. +
  498. +       CPU_DATA = PIC32 {
  499. +           APP_SRC = "code.c";
  500. +           MULTI_STACK = FALSE;
  501. +           ICD2 = TRUE;
  502. +       };
  503. +       MCU_DATA = PIC32 {
  504. +           MODEL = PIC32MX795F512L;
  505. +       };
  506. +
  507. +       BOARD_DATA = NO_BOARD {
  508. +       };
  509. +      
  510. +       KERNEL_TYPE = FP;
  511. +      
  512. +       EE_OPT = "__ADD_LIBS__";
  513. +       EE_OPT = "__USE_TIMER__";
  514. +       EE_OPT = "__USE_EE_TIMER_1__";
  515. +       EE_OPT = "__MICROCHIP_ESK__";
  516. +       EE_OPT = "__USE_LEDS__";
  517. +       EE_OPT = "__USE_BUTTONS__";
  518. +   };
  519. +
  520. +   COUNTER myCounter;
  521. +  
  522. +   TASK TaskLed1 {
  523. +       PRIORITY = 1;
  524. +       STACK = SHARED;
  525. +       SCHEDULE = FULL;
  526. +   };
  527. +  
  528. +   TASK TaskLed2 {
  529. +       PRIORITY = 2;
  530. +       STACK = SHARED;
  531. +       SCHEDULE = FULL;
  532. +   };
  533. +  
  534. +   TASK TaskLed3 {
  535. +       PRIORITY = 3;
  536. +       STACK = SHARED;
  537. +       SCHEDULE = FULL;
  538. +   };
  539. +  
  540. +   COUNTER myCounter;
  541. +
  542. +   ALARM AlarmLed1 {
  543. +       COUNTER = myCounter;
  544. +       ACTION = ACTIVATETASK { TASK = TaskLed1; };
  545. +   };
  546. +
  547. +   ALARM AlarmLed2 {
  548. +       COUNTER = myCounter;
  549. +       ACTION = ACTIVATETASK { TASK = TaskLed2; };
  550. +   };
  551. +
  552. +   ALARM AlarmLed3 {
  553. +       COUNTER = myCounter;
  554. +       ACTION = ACTIVATETASK { TASK = TaskLed3; };
  555. +   };
  556. +  
  557. +
  558. +};
  559. Index: examples/pic32/esk/pic32_esk_base/template.xml
  560. ===================================================================
  561. --- examples/pic32/esk/pic32_esk_base/template.xml  (revision 0)
  562. +++ examples/pic32/esk/pic32_esk_base/template.xml  (revision 0)
  563. @@ -0,0 +1,25 @@
  564. +<?xml version="1.0" encoding="ISO-8859-1"?>
  565. +
  566. +<evidence_example version="1" ID="pic32_ESK_Devices">
  567. +
  568. + <category>pic32/ESK</category>
  569. + <title>Devices Demo</title>
  570. +  
  571. + <small_descr>
  572. + This is the demo to test the Microchip Ethernet Starter Kit board and its devices.
  573. + </small_descr>
  574. +
  575. + <long_descr>
  576. + A minimal EEB demo that demostrates the functions for:
  577. + &lt;ul&gt;
  578. + &lt;li&gt;Leds; &lt;/li&gt;
  579. + &lt;li&gt;Buttons; &lt;/li&gt;
  580. + &lt;/ul&gt;
  581. + </long_descr>
  582. +
  583. + <file_section>
  584. +  <file     name="code.c"/>
  585. +  <file     name="conf.oil"/>
  586. + </file_section>
  587. +
  588. +</evidence_example>
  589. Index: examples/pic32/esk/pic32_esk_base/code.c
  590. ===================================================================
  591. --- examples/pic32/esk/pic32_esk_base/code.c    (revision 0)
  592. +++ examples/pic32/esk/pic32_esk_base/code.c    (revision 0)
  593. @@ -0,0 +1,173 @@
  594. +/* ###*B*###
  595. + * ERIKA Enterprise - a tiny RTOS for small microcontrollers
  596. + *
  597. + * Copyright (C) 2002-2008  Evidence Srl
  598. + *
  599. + * This file is part of ERIKA Enterprise.
  600. + *
  601. + * ERIKA Enterprise is free software; you can redistribute it
  602. + * and/or modify it under the terms of the GNU General Public License
  603. + * version 2 as published by the Free Software Foundation,
  604. + * (with a special exception described below).
  605. + *
  606. + * Linking this code statically or dynamically with other modules is
  607. + * making a combined work based on this code.  Thus, the terms and
  608. + * conditions of the GNU General Public License cover the whole
  609. + * combination.
  610. + *
  611. + * As a special exception, the copyright holders of this library give you
  612. + * permission to link this code with independent modules to produce an
  613. + * executable, regardless of the license terms of these independent
  614. + * modules, and to copy and distribute the resulting executable under
  615. + * terms of your choice, provided that you also meet, for each linked
  616. + * independent module, the terms and conditions of the license of that
  617. + * module.  An independent module is a module which is not derived from
  618. + * or based on this library.  If you modify this code, you may extend
  619. + * this exception to your version of the code, but you are not
  620. + * obligated to do so.  If you do not wish to do so, delete this
  621. + * exception statement from your version.
  622. + *
  623. + * ERIKA Enterprise is distributed in the hope that it will be
  624. + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  625. + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  626. + * GNU General Public License version 2 for more details.
  627. + *
  628. + * You should have received a copy of the GNU General Public License
  629. + * version 2 along with ERIKA Enterprise; if not, write to the
  630. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  631. + * Boston, MA 02110-1301 USA.
  632. + * ###*E*### */
  633. +
  634. + /*
  635. +  * Author: 2014 Angelo Compagnucci <angelo.compagnucci@gmail.com>
  636. +  *
  637. +  */
  638. +
  639. +#include <ee.h>
  640. +#include "cpu/pic32/inc/ee_irqstub.h"
  641. +#include "mcu/microchip_pic32/inc/ee_timer.h"
  642. +
  643. +
  644. +/*  Initial Configuration (fuse bits)
  645. + *
  646. + *  Main Clock       -> SYSCLK = Crystal_Freq / FPLLIDIV * FPLLMUL / FPLLODIV
  647. + *  Peripheral Clock -> PBCLK  = SYSCLK / FPBDIV
  648. +*/
  649. +#pragma config POSCMOD = HS
  650. +#pragma config FNOSC = PRIPLL
  651. +#pragma config FPLLMUL = MUL_20        /* PLL Multiplier */
  652. +#pragma config FPLLIDIV = DIV_2        /* PLL Input Divider */
  653. +#pragma config FPLLODIV = DIV_1    /* PLL Output Divider */
  654. +#pragma config FWDTEN = OFF        /* Watchdog Off */
  655. +#pragma config FPBDIV = DIV_2      /* SYSCLK = 80MHz, PBCLK = 40MHz */
  656. +
  657. +
  658. +/* ************************************************************************** */
  659. +/*                                  Macros                                    */
  660. +/* ************************************************************************** */
  661. +
  662. +/* Timer definitions   */
  663. +#define TICK_PERIOD    20000
  664. +
  665. +
  666. +/* ************************************************************************** */
  667. +/*                               Functions                                    */
  668. +/* ************************************************************************** */
  669. +
  670. +/* Clear the Timer1 interrupt status flag */
  671. +void T1_clear(void)
  672. +{
  673. +   IFS0bits.T1IF = 0;
  674. +}
  675. +
  676. +
  677. +/* This is an ISR Type 2 which is attached to the Timer 1 peripheral IRQ pin
  678. + * The ISR simply calls CounterTick to implement the timing reference
  679. + */
  680. +void T1_cbk(void)
  681. +{
  682. +   /* clear the interrupt source */
  683. +   T1_clear();
  684. +
  685. +   /* count the interrupts, waking up expired alarms */
  686. +   CounterTick(myCounter);
  687. +}
  688. +
  689. +
  690. +/* Program the Timer1 peripheral to raise interrupts */
  691. +void T1_program(void)
  692. +{
  693. +   EE_timer_soft_init(EE_TIMER_1,30000);
  694. +   EE_timer_set_callback(EE_TIMER_1,&T1_cbk);
  695. +   EE_timer_start(EE_TIMER_1);
  696. +}
  697. +
  698. +
  699. +
  700. +/* ************************************************************************** */
  701. +/*                               Tasks                                       */
  702. +/* ************************************************************************** */
  703. +TASK(TaskLed1)
  704. +{
  705. +   if (EE_led_is_on(0)){
  706. +       EE_led_0_off();
  707. +   } else {
  708. +       EE_led_0_on();
  709. +   }
  710. +}
  711. +
  712. +TASK(TaskLed2)
  713. +{
  714. +   if (EE_led_is_on(1)){
  715. +       EE_led_1_off();
  716. +   } else {
  717. +       EE_led_1_on();
  718. +   }
  719. +}
  720. +
  721. +TASK(TaskLed3)
  722. +{
  723. +   if (EE_led_is_on(2)){
  724. +       EE_led_2_off();
  725. +   } else {
  726. +       EE_led_2_on();
  727. +   }
  728. +}
  729. +
  730. +
  731. +void my_button(void)
  732. +{
  733. +   /* Light up all LEDs */
  734. +   if (EE_button_get_S1() == 1)
  735. +       EE_leds_on();
  736. +}
  737. +
  738. +
  739. +
  740. +/* ************************************************************************** */
  741. +/*                                  MAIN                                      */
  742. +/* ************************************************************************** */
  743. +int main(void)
  744. +{
  745. +   /* */
  746. +   EE_system_init();
  747. +
  748. +   /* Init leds */
  749. +   EE_leds_init();
  750. +
  751. +   /* Init devices */
  752. +   EE_buttons_init(&my_button, 0x01);
  753. +
  754. +   /* Program Timer 1 to raise interrupts */
  755. +   T1_program();
  756. +  
  757. +   /* Program cyclic alarms which will fire after an initial offset, and after that periodically */
  758. +   SetRelAlarm(AlarmLed1, 1, 10);
  759. +   SetRelAlarm(AlarmLed2, 3, 10);
  760. +   SetRelAlarm(AlarmLed3, 6, 10);
  761. +
  762. +    /* Forever loop: background activities (if any) should go here */
  763. +   for (;;);
  764. +  
  765. +   return 0;
  766. +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement