source: rtems/c/src/lib/libbsp/arm/atsam/utils/iocopy.c @ 6878519

5
Last change on this file since 6878519 was 6878519, checked in by Christian Mauderer <christian.mauderer@…>, on 02/06/18 at 15:28:28

bsp/atsam: Fix cache / DMA handling in SPI.

This patch fixes the cache handling for the atsam SPI driver. Note that
this solution might doesn't have the best performance for small packets.

  • Property mode set to 100644
File size: 917 bytes
Line 
1/*
2 * Copyright (c) 2018 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Dornierstr. 4
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#include <bsp/iocopy.h>
16
17static void atsam_do_copy(
18  uint8_t *dst,
19  const uint8_t *src,
20  size_t n,
21  bool aligned
22)
23{
24  if (aligned) {
25    while (n > 3) {
26      *(uint32_t *)dst = *(uint32_t *)src;
27      dst += 4;
28      src += 4;
29      n -= 4;
30    }
31  }
32
33  while (n > 0) {
34    *dst = *src;
35    ++dst;
36    ++src;
37    --n;
38  }
39}
40
41void atsam_copy_to_io(void *dst, const void *src, size_t n)
42{
43  atsam_do_copy(dst, src, n, ((uintptr_t)dst) % 4 == 0);
44}
45
46void atsam_copy_from_io(void *dst, const void *src, size_t n)
47{
48  atsam_do_copy(dst, src, n, ((uintptr_t)src) % 4 == 0);
49}
Note: See TracBrowser for help on using the repository browser.