Loading...
Searching...
No Matches
cpu_ebi.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021 Gerson Fernando Budke
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
17
18#include "periph_cpu.h"
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24typedef uint32_t hugemem_ptr_t;
25
26#define HUGEMEM_NULL 0
27
28void ebi_init(void);
29
36static inline uint8_t hugemem_read8(const hugemem_ptr_t from)
37{
38 uint8_t value;
39
40 __asm__ volatile (
41 /* place 24 bit address into r30, r31, RAMPZ
42 * r31:r30 <- %B[from]:%A[from]
43 * RAMPZ <- %C[from]
44 */
45 "movw r30, %A[from] \n\t"
46 "out %[rampz], %C[from] \n\t"
47 /* read byte from 24 bit address
48 * register <- *(RAMPZ + Z)
49 */
50 "ld %[dest], Z \n\t"
51 /* clear ramp */
52 "out %[rampz], __zero_reg__ \n\t"
53 : [dest] "=r"(value)
54 : [from] "r"(from),
55 [rampz] "i"(&RAMPZ)
56 : "r30", "r31"
57 );
58
59 return value;
60}
61
68static inline void hugemem_write8(hugemem_ptr_t to, uint8_t val)
69{
70 __asm__ volatile (
71 /* place 24 bit address into r30, r31, RAMPZ
72 * r31:r30 <- %B[from]:%A[from]
73 * RAMPZ <- %C[from]
74 */
75 "movw r30, %A[to] \n\t"
76 "out %[rampz], %C[to] \n\t"
77 /* write byte to 24 bit address
78 * (RAMPZ + Z) <- register
79 */
80 "st Z, %[val] \n\t"
81 /* clear ramp */
82 "out %[rampz], __zero_reg__ \n\t"
83 :
84 : [to] "r"(to),
85 [val] "r"(val),
86 [rampz] "i"(&RAMPZ)
87 : "r30", "r31"
88 );
89}
90
97uint16_t hugemem_read16(const hugemem_ptr_t from);
98
105void hugemem_write16(hugemem_ptr_t to, uint16_t val);
106
113uint32_t hugemem_read32(const hugemem_ptr_t from);
114
121void hugemem_write32(hugemem_ptr_t to, uint32_t val);
122
132void hugemem_read_block(void *to, const hugemem_ptr_t from, size_t size);
133
143void hugemem_write_block(hugemem_ptr_t to, const void *from, size_t size);
144
145#ifdef __cplusplus
146}
147#endif
148
CPU specific definitions for internal peripheral handling.
void hugemem_write32(hugemem_ptr_t to, uint32_t val)
Store two register pair to external memory pointer.
uint32_t hugemem_read32(const hugemem_ptr_t from)
Load two register pair from external memory pointer.
void hugemem_write_block(hugemem_ptr_t to, const void *from, size_t size)
Write byte stream from internal memory to external memory.
static void hugemem_write8(hugemem_ptr_t to, uint8_t val)
Store byte register to external memory pointer.
Definition cpu_ebi.h:68
static uint8_t hugemem_read8(const hugemem_ptr_t from)
Load byte register from external memory pointer.
Definition cpu_ebi.h:36
uint16_t hugemem_read16(const hugemem_ptr_t from)
Load register pair from external memory pointer.
void hugemem_read_block(void *to, const hugemem_ptr_t from, size_t size)
Read byte stream from external memory to internal memory.
void hugemem_write16(hugemem_ptr_t to, uint16_t val)
Store register pair to external memory pointer.