summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/arm/tms570/startup/bspreset.c
blob: a4b664767487b0fc5c7ec3e351a3993386bf05e8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
 * @file bspreset.c
 *
 * @ingroup tms570
 *
 * @brief Reset code.
 */

/*
 * Copyright (c) 2015 Taller Technologies.
 *
 * @author Martin Galvan <martin.galvan@tallertechnologies.com>
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://www.rtems.org/license/LICENSE.
 */

#include <bsp.h>
#include <bsp/tms570.h>
#include <bsp/start.h>

static void handle_esm_errors(uint32_t esm_irq_channel)
{
  /* ESMR3 errors don't generate interrupts. */
  if (esm_irq_channel < 0x20u) {
    ESMSR1 = 1 << esm_irq_channel;
  } else if (esm_irq_channel < 0x40u) {
    ESMSR2 = 1 << (esm_irq_channel - 32u);
  } else if (esm_irq_channel < 0x60u) {
    ESMSR4 = 1 << (esm_irq_channel - 64u);
  }
}

void bsp_reset(void)
{
  uint32_t esm_irq_channel = ESMIOFFHR - 1;

  if (esm_irq_channel) {
    handle_esm_errors(esm_irq_channel);
  }

  /* Reset the board */
  SYSECR = SYSECR_RESET;
}