source: rc_autosar_rh850/trunk/driver/rscan.c@ 113

Last change on this file since 113 was 113, checked in by ertl-honda, 8 years ago

ドライバーの追加.

File size: 11.9 KB
Line 
1/*
2 * TOPPERS Software
3 * Toyohashi Open Platform for Embedded Real-Time Systems
4 * Software
5 *
6 * Copyright (C) 2015 by Center for Embedded Computing Systems
7 * Graduate School of Information Science, Nagoya Univ., JAPAN
8 *
9 * ã‹L’˜ìŒ ŽÒ‚́CˆÈ‰º‚Ì(1)`(4)‚ÌðŒ‚ð–ž‚½‚·ê‡‚ÉŒÀ‚èC–{ƒ\ƒtƒgƒEƒF
10 * ƒAi–{ƒ\ƒtƒgƒEƒFƒA‚ð‰ü•Ï‚µ‚½‚à‚Ì‚ðŠÜ‚ށDˆÈ‰º“¯‚¶j‚ðŽg—pE•¡»E‰ü
11 * •ÏEÄ”z•ziˆÈ‰ºC—˜—p‚ƌĂԁj‚·‚邱‚Ƃ𖳏ž‚Å‹–‘ø‚·‚éD
12 * (1) –{ƒ\ƒtƒgƒEƒFƒA‚ðƒ\[ƒXƒR[ƒh‚ÌŒ`‚Å—˜—p‚·‚éê‡‚ɂ́Cã‹L‚Ì’˜ì
13 * Œ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’肪C‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[
14 * ƒXƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
15 * (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
16 * —p‚Å‚«‚éŒ`‚ōĔz•z‚·‚éê‡‚ɂ́CÄ”z•z‚É”º‚¤ƒhƒLƒ…
17ƒƒ“ƒgi—˜—p
18 * ŽÒƒ}ƒjƒ…
19ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L
20 * ‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
21 * (3) –{ƒ\ƒtƒgƒEƒFƒA‚ðC‹@Ší‚É‘g‚ݍž‚ނȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
22 * —p‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±
23 * ‚ƁD
24 * (a) Ä”z•z‚É”º‚¤ƒhƒLƒ…
25ƒƒ“ƒgi—˜—pŽÒƒ}ƒjƒ…
26ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜
27 * ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
28 * (b) Ä”z•z‚ÌŒ`‘Ô‚ðC•Ê‚É’è‚ß‚é•û–@‚É‚æ‚Á‚āCTOPPERSƒvƒƒWƒFƒNƒg‚É
29 * •ñ‚·‚邱‚ƁD
30 * (4) –{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹
31 * ŠQ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD
32 * ‚Ü‚½C–{ƒ\ƒtƒgƒEƒFƒA‚̃†[ƒU‚Ü‚½‚̓Gƒ“ƒhƒ†[ƒU‚©‚ç‚Ì‚¢‚©‚Ȃ闝
33 * —R‚ÉŠî‚­¿‹‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð
34 * –Ɛӂ·‚邱‚ƁD
35 *
36 * –{ƒ\ƒtƒgƒEƒFƒA‚́CAUTOSARiAUTomotive Open System ARchitecturejŽd
37 * —l‚ÉŠî‚¢‚Ä‚¢‚éDã‹L‚Ì‹–‘ø‚́CAUTOSAR‚Ì’m“IàŽYŒ ‚ð‹–‘ø‚·‚é‚à‚Ì‚Å
38 * ‚Í‚È‚¢DAUTOSAR‚́CAUTOSARŽd—l‚ÉŠî‚¢‚½ƒ\ƒtƒgƒEƒFƒA‚ð¤—p–Ú“I‚Å—˜
39 * —p‚·‚éŽÒ‚ɑ΂µ‚āCAUTOSARƒp[ƒgƒi[‚ɂȂ邱‚Æ‚ð‹‚ß‚Ä‚¢‚éD
40 *
41 * –{ƒ\ƒtƒgƒEƒFƒA‚́C–³•ÛØ‚Å’ñ‹Ÿ‚³‚ê‚Ä‚¢‚é‚à‚Ì‚Å‚ ‚éDã‹L’˜ìŒ ŽÒ‚¨
42 * ‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚́C–{ƒ\ƒtƒgƒEƒFƒA‚ÉŠÖ‚µ‚āC“Á’è‚ÌŽg—p–Ú“I
43 * ‚ɑ΂·‚é“K‡«‚àŠÜ‚߂āC‚¢‚©‚È‚é•ÛØ‚às‚í‚È‚¢D‚Ü‚½C–{ƒ\ƒtƒgƒEƒF
44 * ƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»
45 * ‚̐ӔC‚𕉂í‚È‚¢D
46 *
47 * $Id: fcan.c 330 2013-08-14 14:12:18Z honda $
48 */
49
50/*
51 * Šî–{•ûj
52 * EŠ„ž‚Ý‚ðŽg—p‚µ‚È‚¢
53 * Eƒ`ƒƒƒlƒ‹–ˆ‚̃oƒbƒtƒ@‚̓[ƒ‹ƒ{ƒbƒNƒX‚Æ•\Œ»‚µ‚Ä0‚©‚ç‚̔ԍ†‚Æ‚µ‚Ĉµ‚¤
54 *
55 * ‘—M
56 * E‘—Mƒoƒbƒtƒ@(16ŒÂ)‚ð—p‚¢‚ĒʐM
57 *
58 * ŽóM
59 * EŽóMƒoƒbƒtƒ@(16ŒÂ)‚ð—p‚¢‚ĒʐM
60 * EŽóMƒ‹[ƒ‹‚Í16ŒÂ
61 */
62#include "Os.h"
63#include "rscan.h"
64#include "t_syslog.h"
65#include "t_stdlib.h"
66#include "sysmod/serial.h"
67#include "sysmod/syslog.h"
68
69
70/*
71 * ’萔’è‹`
72 */
73#define TNUM_RX_BUFF 16U
74
75/* ‘—Mƒoƒbƒtƒ@”ԍ† */
76#define CAN_TX_BUFF_NO(ch, id) ((ch) * 16U + id)
77
78/* ŽóMƒoƒbƒtƒ@”ԍ† */
79#define CAN_RX_BUFF_NO(ch, id) ((ch) * TNUM_RX_BUFF + id)
80
81/* ŽóMƒ‹[ƒ‹” */
82#define TNUM_RXRULE 16U
83
84
85/* ƒrƒbƒg‘€ì—p */
86#define CAN_BIT0 0x00000001U
87#define CAN_BIT1 0x00000002U
88#define CAN_BIT2 0x00000004U
89#define CAN_BIT3 0x00000008U
90#define CAN_BIT4 0x00000010U
91#define CAN_BIT5 0x00000020U
92#define CAN_BIT6 0x00000040U
93#define CAN_BIT7 0x00000080U
94#define CAN_BIT8 0x00000100U
95#define CAN_BIT9 0x00000200U
96#define CAN_BIT10 0x00000400U
97#define CAN_BIT11 0x00000800U
98#define CAN_BIT12 0x00001000U
99#define CAN_BIT13 0x00002000U
100#define CAN_BIT14 0x00004000U
101#define CAN_BIT15 0x00008000U
102#define CAN_BIT16 0x00010000U
103#define CAN_BIT17 0x00020000U
104#define CAN_BIT18 0x00040000U
105#define CAN_BIT19 0x00080000U
106#define CAN_BIT20 0x00100000U
107#define CAN_BIT21 0x00200000U
108#define CAN_BIT22 0x00400000U
109#define CAN_BIT23 0x00800000U
110#define CAN_BIT24 0x01000000U
111#define CAN_BIT25 0x02000000U
112#define CAN_BIT26 0x04000000U
113#define CAN_BIT27 0x08000000U
114#define CAN_BIT28 0x10000000U
115#define CAN_BIT29 0x20000000U
116#define CAN_BIT30 0x40000000U
117#define CAN_BIT31 0x80000000U
118
119/* ƒOƒ[ƒoƒ‹ */
120#define RSCAN0GCFG (*(volatile uint32 *) (RSCAN0_BASE + 0x0084U))
121#define RSCAN0GCTR (*(volatile uint32 *) (RSCAN0_BASE + 0x0088U))
122#define RSCAN0GSTS (*(volatile uint32 *) (RSCAN0_BASE + 0x008CU))
123#define RSCAN0GAFLCFG0 (*(volatile uint32 *) (RSCAN0_BASE + 0x009CU))
124#define RSCAN0GAFLCFG1 (*(volatile uint32 *) (RSCAN0_BASE + 0x00A0U))
125#define RSCAN0GAFLECTR (*(volatile uint32 *) (RSCAN0_BASE + 0x0098U))
126
127/* ŽóMƒoƒbƒtƒ@ */
128#define RSCAN0RMNB (*(volatile uint32 *) (RSCAN0_BASE + 0x00A4U))
129#define RSCAN0RMND(y) (*(volatile uint32 *) (RSCAN0_BASE + 0x00A8U + ((y) * 0x04)))
130#define RSCAN0RMID(id) (*(volatile uint32 *) (RSCAN0_BASE + 0x0600U + ((id) * 0x10)))
131#define RSCAN0RMPTQ(id) (*(volatile uint32 *) (RSCAN0_BASE + 0x0604U + ((id) * 0x10)))
132#define RSCAN0RMDF0(id, byte) (*(volatile uint8 *) (RSCAN0_BASE + 0x0608U + ((id) * 0x10) + (byte)))
133#define RSCAN0RMDF1(id, byte) (*(volatile uint8 *) (RSCAN0_BASE + 0x060CU + ((id) * 0x10) + (byte)))
134
135/* ƒ`ƒƒƒlƒ‹ */
136#define RSCAN0CmCFG(ch) (*(volatile uint32 *) (RSCAN0_BASE + 0x0000U + ((ch) * 0x10U)))
137#define RSCAN0CmCTR(ch) (*(volatile uint32 *) (RSCAN0_BASE + 0x0004U + ((ch) * 0x10U)))
138#define RSCAN0CmSTS(ch) (*(volatile uint32 *) (RSCAN0_BASE + 0x0008U + ((ch) * 0x10U)))
139#define RSCAN0THLCC(ch) (*(volatile uint32 *) (RSCAN0_BASE + 0x0400U + ((ch) * 0x04U)))
140
141/* ŽóMƒ‹[ƒ‹ */
142#define RSCAN0GAFLID(rule) (*(volatile uint32 *) (RSCAN0_BASE + 0x0500U + ((rule) * 0x10U)))
143#define RSCAN0GAFLM(rule) (*(volatile uint32 *) (RSCAN0_BASE + 0x0504U + ((rule) * 0x10U)))
144#define RSCAN0GAFLP0(rule) (*(volatile uint32 *) (RSCAN0_BASE + 0x0508U + ((rule) * 0x10U)))
145#define RSCAN0GAFLP1(rule) (*(volatile uint32 *) (RSCAN0_BASE + 0x050CU + ((rule) * 0x10U)))
146
147/* ‘—ŽóMFIFOƒoƒbƒtƒ@(ŽóM—p) */
148#define RSCAN0CFCC(buf_no) (*(volatile uint32 *) (RSCAN0_BASE + 0x0118U + ((buf_no) * 0x04U)))
149#define RSCAN0CFSTS(buf_no) (*(volatile uint32 *) (RSCAN0_BASE + 0x0178U + ((buf_no) * 0x04U)))
150#define RSCAN0CFPCTR(buf_no) (*(volatile uint32 *) (RSCAN0_BASE + 0x01D8U + ((buf_no) * 0x04U)))
151#define RSCAN0CFID(buf_no) (*(volatile uint32 *) (RSCAN0_BASE + 0x0E80U + ((buf_no) * 0x10U)))
152#define RSCAN0CFPTR(buf_no) (*(volatile uint32 *) (RSCAN0_BASE + 0x0E84U + ((buf_no) * 0x10U)))
153#define RSCAN0CFDF0(buf_no, byte) (*(volatile uint8 *) (RSCAN0_BASE + 0x0E88U + ((buf_no) * 0x10U) + (byte)))
154#define RSCAN0CFDF1(buf_no, byte) (*(volatile uint8 *) (RSCAN0_BASE + 0x0E8CU + ((buf_no) * 0x10U) + (byte)))
155
156/* ‘—Mƒoƒbƒtƒ@ */
157#define RSCAN0TMC(buf_no) (*(volatile uint8 *) (RSCAN0_BASE + 0x0250U + (buf_no)))
158#define RSCAN0TMSTS(buf_no) (*(volatile uint8 *) (RSCAN0_BASE + 0x02D0U + ((buf_no) * 0x01U)))
159#define RSCAN0TMID(buf_no) (*(volatile uint32 *) (RSCAN0_BASE + 0x1000U + ((buf_no) * 0x10U)))
160#define RSCAN0TMPTR(buf_no) (*(volatile uint32 *) (RSCAN0_BASE + 0x1004U + ((buf_no) * 0x10U)))
161#define RSCAN0TMDF0(buf_no, byte) (*(volatile uint8 *) (RSCAN0_BASE + 0x1008U + ((buf_no) * 0x10U) + (byte)))
162#define RSCAN0TMDF1(buf_no, byte) (*(volatile uint8 *) (RSCAN0_BASE + 0x100CU + ((buf_no) * 0x10U) + (byte)))
163
164
165/* ‘—MƒLƒ…
166[ */
167#define RSCAN0TXQCC(ch) (*(volatile uint32 *) (RSCAN0_BASE + 0x03A0U + ((ch) * 0x04U)))
168#define RSCAN0TXQSTS(ch) (*(volatile uint32 *) (RSCAN0_BASE + 0x03C0U + ((ch) * 0x04U)))
169#define RSCAN0TXQPCTR(ch) (*(volatile uint32 *) (RSCAN0_BASE + 0x03E0U + ((ch) * 0x04U)))
170
171/* ‘—M—š—ð */
172#define RSCAN0THLSTS(ch) (*(volatile uint32 *) (RSCAN0_BASE + 0x0420U + ((ch) * 0x04U)))
173#define RSCAN0THLACC(ch) (*(volatile uint32 *) (RSCAN0_BASE + 0x1800U + ((ch) * 0x04U)))
174#define RSCAN0THLPCTR(ch) (*(volatile uint32 *) (RSCAN0_BASE + 0x0440U + ((ch) * 0x04U)))
175
176/* C_ISO_CANOSCƒNƒƒbƒN•ªŽüƒŒƒWƒXƒ^ */
177#define CKSC_ICANOSCD_CTL 0xFFF8AA00U
178
179/* ŽóMƒ‹[ƒ‹”Ý’è(ch0`3)—p */
180#define GAFLCFG0_REG_BIT_SHIFT(ch) (24U - ((ch) * 8U))
181
182/* ŽóMƒ‹[ƒ‹”Ý’è(ch4`5)—p */
183#define GAFLCFG1_REG_BIT_SHIFT(ch) (24U - (((ch) - 4U) * 8U))
184
185
186STATUS
187RsCanInit(uint8 ctrl_id) {
188 /*
189 * ƒOƒ[ƒoƒ‹‚ȏ‰Šú‰»
190 */
191 /* CAN—pRAMƒNƒŠƒAƒXƒe[ƒ^ƒXƒtƒ‰ƒOƒ`ƒFƒbƒN */
192 if ((RSCAN0GSTS & CAN_BIT3) != 0U) {
193 return STATUS_ERROR;
194 }
195
196 /* ƒOƒ[ƒoƒ‹ƒXƒgƒbƒvƒ‚[ƒh‚ð‰ðœ */
197 RSCAN0GCTR &= ~CAN_BIT2;
198
199 /* ƒOƒ[ƒoƒ‹ƒŠƒZƒbƒgƒ‚[ƒh‚É‘JˆÚ */
200 RSCAN0GCTR |= CAN_BIT0;
201
202 /* CAN‚ÅŽg—p‚·‚éƒNƒƒbƒN‚ðCKSCLK_ICANOSC(clk_xincan)‚ɐݒè */
203 RSCAN0GCFG |= CAN_BIT4;
204
205 /*
206 * ƒ`ƒƒƒlƒ‹–ˆ‚̏‰Šú‰»
207 */
208 /* ƒ`ƒƒƒlƒ‹ƒXƒgƒbƒvƒ‚[ƒh‚ð‰ðœ */
209 RSCAN0CmCTR(ctrl_id) &= ~CAN_BIT2;
210
211 /* [CAN259] ƒ`ƒƒƒlƒ‹ƒŠƒZƒbƒgƒ‚[ƒh‚É‘JˆÚ */
212 RSCAN0CmCTR(ctrl_id) |= CAN_BIT0;
213
214 /*
215 * ‘—MÝ’è
216 */
217 /* ‘—MƒLƒ…
218[‚ÍŽg—p‚µ‚È‚¢ */
219 RSCAN0TXQCC(ctrl_id) = 0x00;
220
221 /* ‘—M—š—ðƒoƒbƒtƒ@‚ÍŽg—p‚µ‚È‚¢ */
222 RSCAN0THLCC(ctrl_id) = 0x00;
223
224 /*
225 * ŽóMÝ’è
226 */
227 /* ƒRƒ“ƒgƒ[ƒ‰‚ª4chˆÈã‚©”»’è*/
228 if (ctrl_id < 4U) {
229 /* ŽóMƒ‹[ƒ‹”Ý’è(ch0`3) */
230 RSCAN0GAFLCFG0 |= TNUM_RXRULE << GAFLCFG0_REG_BIT_SHIFT(ctrl_id);
231 }
232 else {
233 /* ŽóMƒ‹[ƒ‹”Ý’è(ch4`5) */
234 RSCAN0GAFLCFG1 |= TNUM_RXRULE << GAFLCFG1_REG_BIT_SHIFT(ctrl_id);
235 }
236
237 /*
238 * ƒ{[ƒŒ[ƒg‚̐ݒè
239 */
240 /* ƒ`ƒƒƒlƒ‹ƒRƒ“ƒtƒBƒOƒŒ[ƒVƒ‡ƒ“Ý’è(ƒ{[ƒŒ[ƒg:500kbps) */
241 RSCAN0CmCFG(ctrl_id) = RSCAN_BRP_500;
242
243 return STATUS_OK;
244}
245
246
247void
248RsCanEnable(uint8 ctrl_id){
249 /* ƒOƒ[ƒoƒ‹ƒŠƒZƒbƒgƒ‚[ƒh‚©‚çƒOƒ[ƒoƒ‹“®ìƒ‚[ƒh‚É‘JˆÚ */
250 RSCAN0GCTR &= ~(CAN_BIT1 | CAN_BIT0);
251
252 /* [CAN261] ƒ`ƒƒƒlƒ‹’ʐMƒ‚[ƒh‚É‘JˆÚ */
253 RSCAN0CmCTR(ctrl_id) &= ~(CAN_BIT1 | CAN_BIT0);
254
255 /* ƒ`ƒƒƒlƒ‹’ʐMƒ‚[ƒh‚É‚È‚é‚܂Ń‹[ƒv(#67) */
256 while ((RSCAN0CmSTS(ctrl_id) &CAN_BIT7) == 0U) {
257 }
258
259 /* ŽóMƒoƒbƒtƒ@”Ý’è */
260 RSCAN0RMNB = TNUM_RX_BUFF * TNUM_CH;
261}
262
263void
264RsCanDisable(uint8 ctrl_id) {
265 /* ƒ`ƒƒƒlƒ‹ƒŠƒZƒbƒgƒ‚[ƒh‚É‘JˆÚ */
266 RSCAN0CmCTR(ctrl_id) &= 0xFFFFFFFDU;
267}
268
269
270STATUS
271RsCanSetTxData(uint8 ctrl_id, uint8 mb_id, uint32 id, uint8 *p_data, uint8 len){
272 uint32 tm_bit;
273 uint8 i;
274
275 /* ‘—M’†‚Ȃ烊ƒ^[ƒ“ */
276 if((RSCAN0TMSTS(CAN_TX_BUFF_NO(ctrl_id, mb_id)) & CAN_BIT0) == CAN_BIT0) {
277 return STATUS_SENDING;
278 }
279
280 RSCAN0TMSTS(CAN_TX_BUFF_NO(ctrl_id, mb_id)) = 0;
281
282 /* CAN-IDÝ’è */
283 RSCAN0TMID(CAN_TX_BUFF_NO(ctrl_id, mb_id)) = id;
284
285 /* DLC‚Æ‘—Mƒ‰ƒxƒ‹î•ñŽæ“¾ */
286 tm_bit = (uint32) len << 28U;
287 tm_bit |= (uint32) 2 << 16U;
288
289 /* DLC‚Æ‘—Mƒ‰ƒxƒ‹Ý’è */
290 RSCAN0TMPTR(CAN_TX_BUFF_NO(ctrl_id, mb_id)) = tm_bit;
291
292 /* [CAN059][CAN427] ƒf[ƒ^Ši”[ */
293 /* ƒf[ƒ^Ý’è(0`3ƒoƒCƒg) */
294 for (i = 0U; i < 4U; i++) {
295 RSCAN0TMDF0(CAN_TX_BUFF_NO(ctrl_id, mb_id), i) = p_data[i];
296 }
297
298 /* 4ƒoƒCƒgˆÈ~‚̃ƒbƒZ[ƒW—L–³”»’è */
299 if (len > 4U) {
300 /* ƒf[ƒ^Ý’è(4`7ƒoƒCƒg) */
301 for (i = 4U; i < len; i++) {
302 RSCAN0TMDF1(CAN_TX_BUFF_NO(ctrl_id, mb_id), (i - 4U)) = p_data[i];
303 }
304 }
305
306 /* ‘—M—v‹ */
307 RSCAN0TMC(CAN_TX_BUFF_NO(ctrl_id, mb_id)) = CAN_BIT0;
308
309 return STATUS_OK;
310}
311
312
313STATUS
314RsCanSetMailBoxInfo(uint8 ctrl_id, uint8 mb_id, uint8 direction,
315 uint8 ide, uint32 id, uint8 mask, uint32 remote){
316 static uint8 rx_rule_index_cnt = 0U;
317 uint8 rx_rule_index;
318
319 if(direction == 1) {
320 return STATUS_ERROR;
321 }
322
323 /* ŽóMƒ‹[ƒ‹ƒe[ƒuƒ‹‘‚«ž‚Ý‹–‰Â */
324 RSCAN0GAFLECTR |= CAN_BIT8;
325
326 /* ƒ‹[ƒ‹”ԍ†‚Ì’Šo */
327 rx_rule_index = rx_rule_index_cnt % 16U;
328
329 /* ƒy[ƒW”ԍ†‚ªØ‚è‘Ö‚í‚é‚©”»’è */
330 if (rx_rule_index == 0U) {
331 /* ƒy[ƒW”ԍ†‚ðÝ’è */
332 RSCAN0GAFLECTR = (CAN_BIT8 | (uint32) (rx_rule_index_cnt / 16U));
333 }
334
335 /* ƒtƒBƒ‹ƒ^ƒ}ƒXƒNÝ’è */
336 RSCAN0GAFLM(rx_rule_index) = (CAN_BIT31 | mask);
337
338 /* ŽóMƒ‹[ƒ‹IDÝ’è(CAN-IDƒŒƒWƒXƒ^) */
339 RSCAN0GAFLID(rx_rule_index) = (uint32) id;
340
341 /* ŽóMƒ‹[ƒ‹‚ðŽg—p‚·‚éŽóMƒoƒbƒtƒ@‚ÌŽw’è */
342 RSCAN0GAFLP0(rx_rule_index) = (1 << 15U) | (1 << 16U) | (mb_id << 8U);
343
344 /* ŽóMƒ‹[ƒ‹ƒCƒ“ƒfƒbƒNƒX‚ðƒCƒ“ƒNƒŠƒƒ“ƒg */
345 rx_rule_index_cnt++;
346
347 /* ŽóMƒ‹[ƒ‹ƒe[ƒuƒ‹‘‚«ž‚Ý‹ÖŽ~ */
348 RSCAN0GAFLECTR &= ~CAN_BIT8;
349
350 return STATUS_OK;
351 }
352
353
354
355STATUS
356RsCanGetRxData(uint8 ctrl_id, uint8 mb_id, uint8 *p_data, uint8 *p_len){
357 uint8 local_dlc;
358 uint8 i;
359 uint8 bufid;
360
361 bufid = CAN_RX_BUFF_NO(ctrl_id, mb_id);
362
363 /* ŽóM‚µ‚Ä‚¢‚é‚©Šm”F ToDo Œ»ó‚ÍŒˆ‚ß‚¤‚¿ */
364 if((RSCAN0RMND(bufid / 32) & (1U << (bufid % 32))) == 0) {
365 *p_len = 0;
366 return STATUS_EMPTY;
367 }
368
369 /* ƒtƒ‰ƒOƒNƒŠƒA */
370 RSCAN0RMND(bufid / 32) = ~(1U << (bufid % 32));
371
372 local_dlc = (RSCAN0RMPTQ(mb_id) >> 28);
373 *p_len = local_dlc;
374
375 /* ƒf[ƒ^Ši”[(0`3ƒoƒCƒg) */
376 for (i = 0U; i < 4U; i++) {
377 p_data[i] = RSCAN0RMDF0(mb_id, i);
378 }
379
380 /* ƒf[ƒ^‚ª4byteˆÈã‚©”»’è */
381 if (local_dlc > 4U) {
382 /* ƒf[ƒ^Ši”[(4`7ƒoƒCƒg) */
383 for (i = 4U; i < local_dlc; i++) {
384 p_data[i] = RSCAN0RMDF1(mb_id, (i - 4U));
385 }
386 }
387
388 return STATUS_OK;
389}
Note: See TracBrowser for help on using the repository browser.