<commit_before>#include "DSP2833x_Device.h"     // Device Header Include File
#include "CanTest.h"
#include "usDelay.h"
#include "DSP2833x_ECan.h"
#define BLINK_LED() GpioDataRegs.GPATOGGLE.bit.GPIO26 = 1

// Global variable for this example
Uint32 ErrorCount;
Uint32 PassCount;
Uint32 MessageReceivedCount;

Uint32 TestMbox1;
Uint32 TestMbox2;
Uint32 TestMbox3;

struct ECAN_REGS ECanbShadow;

// Prototype statements for functions found within this file.
static void
mailbox_check (int32 T1, int32 T2, int32 T3);
static void
mailbox_read (int16 i);
void
init_interrupt ();
void
UserSetInt ();

void
configureEcanB (void)
{
  MessageReceivedCount = 0;
  ErrorCount = 0;
  PassCount = 0;

  TestMbox1 = 0;
  TestMbox2 = 0;
  TestMbox3 = 0;

  UserSetInt (); // Initialize interrupt and enable interrupt

  InitECanb ();
  // Mailboxs can be written to 16-bits or 32-bits at a time
  // Write to the MSGID field of TRANSMIT mailboxes MBOX0 - 15
  ECanbMboxes.MBOX0.MSGID.all = 0x9555AAA0;
  ECanbMboxes.MBOX1.MSGID.all = 0x9555AAA1;
  ECanbMboxes.MBOX2.MSGID.all = 0x9555AAA2;
  ECanbMboxes.MBOX3.MSGID.all = 0x9555AAA3;
  ECanbMboxes.MBOX4.MSGID.all = 0x9555AAA4;
  ECanbMboxes.MBOX5.MSGID.all = 0x9555AAA5;
  ECanbMboxes.MBOX6.MSGID.all = 0x9555AAA6;
  ECanbMboxes.MBOX7.MSGID.all = 0x9555AAA7;
  ECanbMboxes.MBOX8.MSGID.all = 0x9555AAA8;
  ECanbMboxes.MBOX9.MSGID.all = 0x9555AAA9;
  ECanbMboxes.MBOX10.MSGID.all = 0x9555AAAA;
  ECanbMboxes.MBOX11.MSGID.all = 0x9555AAAB;
  ECanbMboxes.MBOX12.MSGID.all = 0x9555AAAC;
  ECanbMboxes.MBOX13.MSGID.all = 0x9555AAAD;
  ECanbMboxes.MBOX14.MSGID.all = 0x9555AAAE;
  ECanbMboxes.MBOX15.MSGID.all = 0x9555AAAF;

  // Write to the MSGID field of RECEIVE mailboxes MBOX16 - 31
  ECanbMboxes.MBOX16.MSGID.all = 0x9555AAA0;
  ECanbMboxes.MBOX17.MSGID.all = 0x9555AAA1;
  ECanbMboxes.MBOX18.MSGID.all = 0x9555AAA2;
  ECanbMboxes.MBOX19.MSGID.all = 0x9555AAA3;
  ECanbMboxes.MBOX20.MSGID.all = 0x9555AAA4;
  ECanbMboxes.MBOX21.MSGID.all = 0x9555AAA5;
  ECanbMboxes.MBOX22.MSGID.all = 0x9555AAA6;
  ECanbMboxes.MBOX23.MSGID.all = 0x9555AAA7;
  ECanbMboxes.MBOX24.MSGID.all = 0x9555AAA8;
  ECanbMboxes.MBOX25.MSGID.all = 0x9555AAA9;
  ECanbMboxes.MBOX26.MSGID.all = 0x9555AAAA;
  ECanbMboxes.MBOX27.MSGID.all = 0x9555AAAB;
  ECanbMboxes.MBOX28.MSGID.all = 0x9555AAAC;
  ECanbMboxes.MBOX29.MSGID.all = 0x9555AAAD;
  ECanbMboxes.MBOX30.MSGID.all = 0x9555AAAE;
  ECanbMboxes.MBOX31.MSGID.all = 0x9555AAAF;

  // Configure Mailboxes 0-15 as Tx, 16-31 as Rx
  // Since this write is to the entire register (instead of a bit
  // field) a shadow register is not required.
  ECanbRegs.CANMD.all = 0xFFFF0000;

  // Enable all Mailboxes */
  // Since this write is to the entire register (instead of a bit
  // field) a shadow register is not required.
  ECanbRegs.CANME.all = 0xFFFFFFFF;

  // Specify that 8 bits will be sent/received
  ECanbMboxes.MBOX0.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX1.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX2.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX3.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX4.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX5.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX6.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX7.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX8.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX9.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX10.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX11.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX12.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX13.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX14.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX15.MSGCTRL.bit.DLC = 8;

  // Write to the mailbox RAM field of MBOX0 - 15
  ECanbMboxes.MBOX0.MDL.all = 0x0000AAA0;
  ECanbMboxes.MBOX0.MDH.all = 0x89ABCDEF;

  ECanbMboxes.MBOX1.MDL.all = 0x9555AAA1;
  ECanbMboxes.MBOX1.MDH.all = 0x89ABCDEF;

//	ECanbMboxes.MBOX2.MDL.all = 0x9555AAA2;
//	ECanbMboxes.MBOX2.MDH.all = 0x89ABCDAA;
//
//	ECanbMboxes.MBOX3.MDL.all = 0x9555AAA3;
//	ECanbMboxes.MBOX3.MDH.all = 0x89ABCDEF;
//
//	ECanbMboxes.MBOX4.MDL.all = 0x9555AAA4;
//	ECanbMboxes.MBOX4.MDH.all = 0x89ABCDEF;
//
//	ECanbMboxes.MBOX5.MDL.all = 0x9555AAA5;
//	ECanbMboxes.MBOX5.MDH.all = 0x89ABCDEF;
//
//	ECanbMboxes.MBOX6.MDL.all = 0x9555AAA6;
//	ECanbMboxes.MBOX6.MDH.all = 0x89ABCDEF;
//
//	ECanbMboxes.MBOX7.MDL.all = 0x9555AAA7;
//	ECanbMboxes.MBOX7.MDH.all = 0x89ABCDEF;
//
//	ECanbMboxes.MBOX8.MDL.all = 0x9555AAA8;
//	ECanbMboxes.MBOX8.MDH.all = 0x89ABCDEF;
//
//	ECanbMboxes.MBOX9.MDL.all = 0x9555AAA9;
//	ECanbMboxes.MBOX9.MDH.all = 0x89ABCDEF;
//
//	ECanbMboxes.MBOX10.MDL.all = 0x9555AAAA;
//	ECanbMboxes.MBOX10.MDH.all = 0x89ABCDEF;
//
//	ECanbMboxes.MBOX11.MDL.all = 0x9555AAAB;
//	ECanbMboxes.MBOX11.MDH.all = 0x89ABCDEF;
//
//	ECanbMboxes.MBOX12.MDL.all = 0x9555AAAC;
//	ECanbMboxes.MBOX12.MDH.all = 0x89ABCDEF;
//
//	ECanbMboxes.MBOX13.MDL.all = 0x9555AAAD;
//	ECanbMboxes.MBOX13.MDH.all = 0x89ABCDEF;
//
//	ECanbMboxes.MBOX14.MDL.all = 0x9555AAAE;
//	ECanbMboxes.MBOX14.MDH.all = 0x89ABCDEF;
//
//	ECanbMboxes.MBOX15.MDL.all = 0x9555AAAF;
//	ECanbMboxes.MBOX15.MDH.all = 0x89ABCDEF;

  // Configure the eCAN for self test mode
  // Enable the enhanced features of the eCAN.
  EALLOW;
  ECanbShadow.CANMC.all = ECanbRegs.CANMC.all;
  ECanbShadow.CANMC.bit.STM = 1;    // Configure CAN for self-test mode
  ECanbShadow.CANMC.bit.STM = 0;    // Configure CAN for normal mode
  ECanbRegs.CANMC.all = ECanbShadow.CANMC.all;
  EDIS;

  //Initial for interupt
  EALLOW;
//  ECanbRegs.CANMIM.all = 0x04;
  ECanbRegs.CANMIM.all = 0xFFFFFFFF;
  EDIS;

  EALLOW;
//  ECanbRegs.CANMIL.all = 0x04;
  ECanbRegs.CANMIL.all = 0xFFFFFFFF;
  EDIS;

  EALLOW;
  ECanbShadow.CANGIF1.all = ECanbRegs.CANGIF1.all;
  ECanbShadow.CANGIF1.bit.GMIF1 = 1;
  ECanbRegs.CANGIF1.all = ECanbShadow.CANGIF1.all;
  EDIS;

  EALLOW;
  ECanbShadow.CANGIM.all = ECanbRegs.CANGIM.all;
  ECanbShadow.CANGIM.bit.GIL = 1;
  ECanbShadow.CANGIM.bit.I1EN = 1;<commit_msg>Enable CAN clock in the configureEcanB to make sure CAN bus module is enabled.<commit_after>#include "DSP2833x_Device.h"     // Device Header Include File
#include "CanTest.h"
#include "usDelay.h"
#include "DSP2833x_ECan.h"
#define BLINK_LED() GpioDataRegs.GPATOGGLE.bit.GPIO26 = 1

// Global variable for this example
Uint32 ErrorCount;
Uint32 PassCount;
Uint32 MessageReceivedCount;

Uint32 TestMbox1;
Uint32 TestMbox2;
Uint32 TestMbox3;

struct ECAN_REGS ECanbShadow;

// Prototype statements for functions found within this file.
static void
mailbox_check (int32 T1, int32 T2, int32 T3);
static void
mailbox_read (int16 i);
void
init_interrupt ();
void
UserSetInt ();

void
configureEcanB (void)
{
  MessageReceivedCount = 0;
  ErrorCount = 0;
  PassCount = 0;

  TestMbox1 = 0;
  TestMbox2 = 0;
  TestMbox3 = 0;

  UserSetInt (); // Initialize interrupt and enable interrupt

  InitECanb ();
  // Mailboxs can be written to 16-bits or 32-bits at a time
  // Write to the MSGID field of TRANSMIT mailboxes MBOX0 - 15
  ECanbMboxes.MBOX0.MSGID.all = 0x9555AAA0;
  ECanbMboxes.MBOX1.MSGID.all = 0x9555AAA1;
  ECanbMboxes.MBOX2.MSGID.all = 0x9555AAA2;
  ECanbMboxes.MBOX3.MSGID.all = 0x9555AAA3;
  ECanbMboxes.MBOX4.MSGID.all = 0x9555AAA4;
  ECanbMboxes.MBOX5.MSGID.all = 0x9555AAA5;
  ECanbMboxes.MBOX6.MSGID.all = 0x9555AAA6;
  ECanbMboxes.MBOX7.MSGID.all = 0x9555AAA7;
  ECanbMboxes.MBOX8.MSGID.all = 0x9555AAA8;
  ECanbMboxes.MBOX9.MSGID.all = 0x9555AAA9;
  ECanbMboxes.MBOX10.MSGID.all = 0x9555AAAA;
  ECanbMboxes.MBOX11.MSGID.all = 0x9555AAAB;
  ECanbMboxes.MBOX12.MSGID.all = 0x9555AAAC;
  ECanbMboxes.MBOX13.MSGID.all = 0x9555AAAD;
  ECanbMboxes.MBOX14.MSGID.all = 0x9555AAAE;
  ECanbMboxes.MBOX15.MSGID.all = 0x9555AAAF;

  // Write to the MSGID field of RECEIVE mailboxes MBOX16 - 31
  ECanbMboxes.MBOX16.MSGID.all = 0x9555AAA0;
  ECanbMboxes.MBOX17.MSGID.all = 0x9555AAA1;
  ECanbMboxes.MBOX18.MSGID.all = 0x9555AAA2;
  ECanbMboxes.MBOX19.MSGID.all = 0x9555AAA3;
  ECanbMboxes.MBOX20.MSGID.all = 0x9555AAA4;
  ECanbMboxes.MBOX21.MSGID.all = 0x9555AAA5;
  ECanbMboxes.MBOX22.MSGID.all = 0x9555AAA6;
  ECanbMboxes.MBOX23.MSGID.all = 0x9555AAA7;
  ECanbMboxes.MBOX24.MSGID.all = 0x9555AAA8;
  ECanbMboxes.MBOX25.MSGID.all = 0x9555AAA9;
  ECanbMboxes.MBOX26.MSGID.all = 0x9555AAAA;
  ECanbMboxes.MBOX27.MSGID.all = 0x9555AAAB;
  ECanbMboxes.MBOX28.MSGID.all = 0x9555AAAC;
  ECanbMboxes.MBOX29.MSGID.all = 0x9555AAAD;
  ECanbMboxes.MBOX30.MSGID.all = 0x9555AAAE;
  ECanbMboxes.MBOX31.MSGID.all = 0x9555AAAF;

  // Configure Mailboxes 0-15 as Tx, 16-31 as Rx
  // Since this write is to the entire register (instead of a bit
  // field) a shadow register is not required.
  ECanbRegs.CANMD.all = 0xFFFF0000;

  // Enable all Mailboxes */
  // Since this write is to the entire register (instead of a bit
  // field) a shadow register is not required.
  ECanbRegs.CANME.all = 0xFFFFFFFF;

  // Specify that 8 bits will be sent/received
  ECanbMboxes.MBOX0.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX1.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX2.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX3.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX4.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX5.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX6.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX7.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX8.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX9.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX10.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX11.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX12.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX13.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX14.MSGCTRL.bit.DLC = 8;
  ECanbMboxes.MBOX15.MSGCTRL.bit.DLC = 8;

  // Write to the mailbox RAM field of MBOX0 - 15
  ECanbMboxes.MBOX0.MDL.all = 0x0000AAA0;
  ECanbMboxes.MBOX0.MDH.all = 0x89ABCDEF;

  ECanbMboxes.MBOX1.MDL.all = 0x9555AAA1;
  ECanbMboxes.MBOX1.MDH.all = 0x89ABCDEF;

//	ECanbMboxes.MBOX2.MDL.all = 0x9555AAA2;
//	ECanbMboxes.MBOX2.MDH.all = 0x89ABCDAA;
//
//	ECanbMboxes.MBOX3.MDL.all = 0x9555AAA3;
//	ECanbMboxes.MBOX3.MDH.all = 0x89ABCDEF;
//
//	ECanbMboxes.MBOX4.MDL.all = 0x9555AAA4;
//	ECanbMboxes.MBOX4.MDH.all = 0x89ABCDEF;
//
//	ECanbMboxes.MBOX5.MDL.all = 0x9555AAA5;
//	ECanbMboxes.MBOX5.MDH.all = 0x89ABCDEF;
//
//	ECanbMboxes.MBOX6.MDL.all = 0x9555AAA6;
//	ECanbMboxes.MBOX6.MDH.all = 0x89ABCDEF;
//
//	ECanbMboxes.MBOX7.MDL.all = 0x9555AAA7;
//	ECanbMboxes.MBOX7.MDH.all = 0x89ABCDEF;
//
//	ECanbMboxes.MBOX8.MDL.all = 0x9555AAA8;
//	ECanbMboxes.MBOX8.MDH.all = 0x89ABCDEF;
//
//	ECanbMboxes.MBOX9.MDL.all = 0x9555AAA9;
//	ECanbMboxes.MBOX9.MDH.all = 0x89ABCDEF;
//
//	ECanbMboxes.MBOX10.MDL.all = 0x9555AAAA;
//	ECanbMboxes.MBOX10.MDH.all = 0x89ABCDEF;
//
//	ECanbMboxes.MBOX11.MDL.all = 0x9555AAAB;
//	ECanbMboxes.MBOX11.MDH.all = 0x89ABCDEF;
//
//	ECanbMboxes.MBOX12.MDL.all = 0x9555AAAC;
//	ECanbMboxes.MBOX12.MDH.all = 0x89ABCDEF;
//
//	ECanbMboxes.MBOX13.MDL.all = 0x9555AAAD;
//	ECanbMboxes.MBOX13.MDH.all = 0x89ABCDEF;
//
//	ECanbMboxes.MBOX14.MDL.all = 0x9555AAAE;
//	ECanbMboxes.MBOX14.MDH.all = 0x89ABCDEF;
//
//	ECanbMboxes.MBOX15.MDL.all = 0x9555AAAF;
//	ECanbMboxes.MBOX15.MDH.all = 0x89ABCDEF;

  // enable sys clock for ecanb
  EALLOW;
  SysCtrlRegs.PCLKCR0.bit.ECANBENCLK = 1;    // eCAN-B
  EDIS;

  // Configure the eCAN for self test mode
  // Enable the enhanced features of the eCAN.
  EALLOW;
  ECanbShadow.CANMC.all = ECanbRegs.CANMC.all;
  ECanbShadow.CANMC.bit.STM = 1;    // Configure CAN for self-test mode
  ECanbShadow.CANMC.bit.STM = 0;    // Configure CAN for normal mode
  ECanbRegs.CANMC.all = ECanbShadow.CANMC.all;
  EDIS;

  //Initial for interupt
  EALLOW;
//  ECanbRegs.CANMIM.all = 0x04;
  ECanbRegs.CANMIM.all = 0xFFFFFFFF;
  EDIS;

  EALLOW;
//  ECanbRegs.CANMIL.all = 0x04;
  ECanbRegs.CANMIL.all = 0xFFFFFFFF;
  EDIS;

  EALLOW;
  ECanbShadow.CANGIF1.all = ECanbRegs.CANGIF1.all;
  ECanbShadow.CANGIF1.bit.GMIF1 = 1;
  ECanbRegs.CANGIF1.all = ECanbShadow.CANGIF1.all;
  EDIS;

  EALLOW;
  ECanbShadow.CANGIM.all = ECanbRegs.CANGIM.all;
  ECanbShadow.CANGIM.bit.GIL = 1;
  ECanbShadow.CANGIM.bit.I1EN = 1;
{'fraction_non_alphanumeric': 0.12212389380530973, 'fraction_numerical': 0.09254108723135272, 'mean_word_length': 3.631537861046058, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 6, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5471552', 'n_tokens_mistral': 6413, 'n_tokens_neox': 5698, 'n_words': 838}