RTEMS 6.1-rc7
Loading...
Searching...
No Matches
tm27.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
11/*
12 * Copyright (c) 2023 embedded brains GmbH & Co. KG
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#ifndef _RTEMS_TMTEST27
37#error "This is an RTEMS internal file you must not include directly."
38#endif
39
40#ifndef __tm27_h
41#define __tm27_h
42
43#include <rtems.h>
44
45#include <bsp/irq.h>
46#include <bsp/tms570.h>
47#include <rtems/score/armv4.h>
48
49#define MUST_WAIT_FOR_INTERRUPT 1
50
51#define TM27_INTERRUPT_VECTOR_DEFAULT TMS570_IRQ_TIMER_3
52
53#define TM27_INTERRUPT_VECTOR_ALTERNATIVE TMS570_IRQ_TIMER_1
54
55static inline void Install_tm27_vector( rtems_interrupt_handler handler )
56{
57 static rtems_interrupt_entry entry_2;
58 static rtems_interrupt_entry entry_3;
59
60 TMS570_RTI.CNT[1].CPUCx = 1;
61 TMS570_RTI.CNT[1].UCx = 0;
62 TMS570_RTI.CNT[1].FRCx = 0;
63 TMS570_RTI.CMP[1].COMPx = 1;
64 TMS570_RTI.CMP[1].UDCPx = 1;
65 TMS570_RTI.CMP[2].COMPx = 1;
66 TMS570_RTI.CMP[2].UDCPx = 1;
67 TMS570_RTI.CMP[3].COMPx = 1;
68 TMS570_RTI.CMP[3].UDCPx = 1;
69 TMS570_RTI.COMPCTRL |= TMS570_RTI_COMPCTRL_COMPSEL1 |
70 TMS570_RTI_COMPCTRL_COMPSEL2 |
71 TMS570_RTI_COMPCTRL_COMPSEL3;
72 TMS570_RTI.GCTRL |= TMS570_RTI_GCTRL_CNT1EN;
73
74 rtems_interrupt_entry_initialize(
75 &entry_2,
76 handler,
77 NULL,
78 "tm27"
79 );
81 TMS570_IRQ_TIMER_2,
83 &entry_2
84 );
85
86 rtems_interrupt_entry_initialize(
87 &entry_3,
88 handler,
89 NULL,
90 "tm27"
91 );
93 TMS570_IRQ_TIMER_3,
95 &entry_3
96 );
97}
98
99static inline void Cause_tm27_intr(void)
100{
101 TMS570_RTI.SETINTENA = TMS570_RTI_SETINTENA_SETINT3;
102}
103
104static inline void Clear_tm27_intr(void)
105{
106 TMS570_RTI.CLEARINTENA = TMS570_RTI_CLEARINTENA_CLEARINT2 |
107 TMS570_RTI_CLEARINTENA_CLEARINT3;
108}
109
110static inline void Lower_tm27_intr(void)
111{
112 TMS570_RTI.SETINTENA = TMS570_RTI_SETINTENA_SETINT2;
113 (void) _ARMV4_Status_irq_enable();
114}
115
116static inline rtems_status_code _TM27_Raise_alternative(void)
117{
118 TMS570_RTI.SETINTENA = TMS570_RTI_SETINTENA_SETINT1;
119 return RTEMS_SUCCESSFUL;
120}
121
122static inline rtems_status_code _TM27_Clear_alternative(void)
123{
124 TMS570_RTI.CLEARINTENA = TMS570_RTI_CLEARINTENA_CLEARINT1;
125 return RTEMS_SUCCESSFUL;
126}
127
128#endif /* __tm27_h */
This header file provides interfaces of the ARMv4 architecture support.
rtems_status_code rtems_interrupt_entry_install(rtems_vector_number vector, rtems_option options, rtems_interrupt_entry *entry)
Installs the interrupt entry at the interrupt vector.
Definition: irq-generic.c:264
#define RTEMS_INTERRUPT_SHARED
This interrupt handler install option allows that the interrupt handler may share the interrupt vecto...
Definition: intr.h:960
void(* rtems_interrupt_handler)(void *)
Interrupt handler routines shall have this type.
Definition: intr.h:1030
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:85
@ RTEMS_SUCCESSFUL
This status code indicates successful completion of a requested operation.
Definition: status.h:90
This header file defines the RTEMS Classic API.
This structure represents an interrupt entry.
Definition: intr.h:1070
This header file provides TMS570 interfaces.