source: rtems/c/src/lib/libbsp/arm/tms570/hwinit/tms570_selftest_par_can.c @ b2ed712

Last change on this file since b2ed712 was 29430a3, checked in by Pavel Pisa <pisa@…>, on Sep 22, 2016 at 7:50:59 AM

arm/tms570: include hardware initialization and selftest based on Ti HalCoGen? generated files.

The configuration is specific for TMS570LS3137 based HDK.
Pins configuration can be easily changed in

rtems/c/src/lib/libbsp/arm/tms570/hwinit/init_pinmux.c

file.

The list tms570_selftest_par_list in the file

rtems/c/src/lib/libbsp/arm/tms570/hwinit/bspstarthooks-hwinit.c

specifies peripherals which health status is examined
by parity self-test at BSP start-up. It can be easily
modified for other TMS570 family members variants same
as the selection of other tests in bspstarthooks-hwinit.c.

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/**
2 * @file tms570_selftest_par_can.c
3 *
4 * @ingroup tms570
5 *
6 * @brief Test CAN module parity based protection logic to work.
7 */
8/*
9 * Copyright (c) 2016 Pavel Pisa <pisa@cmp.felk.cvut.cz>
10 *
11 * Czech Technical University in Prague
12 * Zikova 1903/4
13 * 166 36 Praha 6
14 * Czech Republic
15 *
16 * The license and distribution terms for this file may be
17 * found in the file LICENSE in this distribution or at
18 * http://www.rtems.org/license/LICENSE.
19 *
20 * Algorithms are based on Ti manuals and Ti HalCoGen generated
21 * code.
22 */
23
24#include <stdint.h>
25#include <stddef.h>
26#include <bsp/tms570.h>
27#include "tms570_selftest.h"
28#include "tms570_selftest_parity.h"
29
30/**
31 * @brief run test to check that parity protection works for CAN modules RAM
32 *
33 * @param[in] desc module registers addresses end ESM channels descriptor
34 *
35 * @return Void, in the case of error invokes bsp_selftest_fail_notification()
36 *
37 * The descriptor provides address of the module registers and address
38 * of internal RAM memory and corresponding parity area test access window.
39 */
40void tms570_selftest_par_check_can( const tms570_selftest_par_desc_t *desc )
41{
42  volatile uint32_t       test_read_data;
43  volatile tms570_dcan_t *can_regs = (volatile tms570_dcan_t *) desc->fnc_data;
44  uint32_t                canctl_bak = can_regs->CTL;
45  uint32_t                canctl_pmd;
46  int                     perr;
47
48  /* Set TEST mode and enable parity checking */
49  /* Disable parity, init mode, TEST mode */
50  canctl_pmd = TMS570_DCAN_CTL_PMD_SET( 0, 0x5 );
51  can_regs->CTL = canctl_pmd | TMS570_DCAN_CTL_Test | TMS570_DCAN_CTL_Init;
52
53  /* Enable RAM Direct Access mode */
54  can_regs->TEST = TMS570_DCAN_TEST_RDA;
55
56  /* flip parity bit */
57  *desc->par_loc ^= desc->par_xor;
58
59  /* Disable TEST mode */
60  canctl_pmd = TMS570_DCAN_CTL_PMD_SET( 0, 0xA );
61  can_regs->CTL = canctl_pmd | TMS570_DCAN_CTL_Test;
62
63  /* read to cause parity error */
64  test_read_data = *desc->ram_loc;
65  (void) test_read_data;
66
67  /* check if ESM channel is flagged */
68  perr = tms570_esm_channel_sr_get( desc->esm_prim_grp, desc->esm_prim_chan );
69
70  if ( !perr ) {
71    /* RAM parity error was not flagged to ESM. */
72    bsp_selftest_fail_notification( desc->fail_code );
73  } else {
74    /* clear ESM flag */
75    tms570_esm_channel_sr_clear( desc->esm_prim_grp, desc->esm_prim_chan );
76
77    /* Set TEST mode and enable parity checking */
78    canctl_pmd = TMS570_DCAN_CTL_PMD_SET( 0, 0x5 );
79    can_regs->CTL = canctl_pmd | TMS570_DCAN_CTL_Test | TMS570_DCAN_CTL_Init;
80
81    /* Revert back to correct data by flipping parity location */
82    *desc->par_loc ^= desc->par_xor;
83  }
84
85  /* Disable RAM Direct Access mode */
86  can_regs->TEST = 0x00000000U;
87
88  /* Restore CTL register */
89  can_regs->CTL = canctl_bak;
90
91  /* Read Error and Status register to clear Parity Error bit */
92  test_read_data = can_regs->ES;
93}
Note: See TracBrowser for help on using the repository browser.