Browse Source

Merge remote-tracking branch 'PaulStoffregen/master'

main
duff2013 8 years ago
parent
commit
81a00b5da3
4 changed files with 99 additions and 4 deletions
  1. +4
    -0
      teensy3/avr_functions.h
  2. +3
    -3
      teensy3/kinetis.h
  3. +91
    -0
      teensy3/memset.S
  4. +1
    -1
      teensy3/usb_desc.h

+ 4
- 0
teensy3/avr_functions.h View File

@@ -94,10 +94,14 @@ static inline void eeprom_update_block(const void *buf, void *addr, uint32_t len

char * ultoa(unsigned long val, char *buf, int radix);
char * ltoa(long val, char *buf, int radix);

#if defined(_NEWLIB_VERSION) && (__NEWLIB__ < 2 || __NEWLIB__ == 2 && __NEWLIB_MINOR__ < 2)
static inline char * utoa(unsigned int val, char *buf, int radix) __attribute__((always_inline, unused));
static inline char * utoa(unsigned int val, char *buf, int radix) { return ultoa(val, buf, radix); }
static inline char * itoa(int val, char *buf, int radix) __attribute__((always_inline, unused));
static inline char * itoa(int val, char *buf, int radix) { return ltoa(val, buf, radix); }
#endif

char * dtostrf(float val, int width, unsigned int precision, char *buf);



+ 3
- 3
teensy3/kinetis.h View File

@@ -1608,9 +1608,9 @@ enum IRQ_NUMBER_t {
#define DMA_TCD_CITER_ELINKYES_CITER_MASK 0x01FF
#define DMA_TCD_NBYTES_SMLOE ((uint32_t)1<<31) // Source Minor Loop Offset Enable
#define DMA_TCD_NBYTES_DMLOE ((uint32_t)1<<30) // Destination Minor Loop Offset Enable
#define DMA_TCD_NBYTES_MLOFFNO_NBYTES(n) ((uint32_t)(n)) // NBytes transfer count when minor loop disabled
#define DMA_TCD_NBYTES_MLOFFYES_NBYTES(n) ((uint32_t)(n & 0x1F)) // NBytes transfer count when minor loop enabled
#define DMA_TCD_NBYTES_MLOFFYES_MLOFF(n) ((uint32_t)(n & 0xFFFFF)<<10) // Offset
#define DMA_TCD_NBYTES_MLOFFNO_NBYTES(n) ((uint32_t)((n) & 0x3FFFFFFF)) // NBytes transfer count when minor loop disabled
#define DMA_TCD_NBYTES_MLOFFYES_NBYTES(n) ((uint32_t)((n) & 0x1F)) // NBytes transfer count when minor loop enabled
#define DMA_TCD_NBYTES_MLOFFYES_MLOFF(n) ((uint32_t)((n) & 0xFFFFF)<<10) // Minor loop offset

#if DMA_NUM_CHANNELS >= 4
#define DMA_TCD0_SADDR (*(volatile const void * volatile *)0x40009000) // TCD Source Address

+ 91
- 0
teensy3/memset.S View File

@@ -0,0 +1,91 @@
/*
* Copyright (c) 2014 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//#include <asm.h>
//#include <arch/arm/cores.h>
#if defined (__ARM_ARCH_7M__) || defined (__ARM_ARCH_7EM__)
.global memset
.text
.syntax unified
.thumb
.align 2

/* void *memset(void *s, int c, size_t n); */
.type memset, %function
.thumb_func
memset:
//FUNCTION(memset)
// save the original pointer
push { r0, lr }

// check for zero length
cbz r2, .L_done

// short memsets aren't worth optimizing and make sure we have
// enough headroom to try to do dwordwise move optimization
cmp r2, #16
blt .L_bytewise

// see how many bytes we need to move to align to dword boundaries
and r3, r0, #7
cbz r3, .L_prepare_dwordwise
rsb r3, #8
subs r2, r3

.L_bytewise_align:
// bytewise to align memset
subs r3, r3, #1
strb r1, [r0], #1
bgt .L_bytewise_align

.L_prepare_dwordwise:
// fill a pair of 32 bit registers with the 8 bit value
uxtb r1, r1
orr r1, r1, r1, lsl #8
orr r1, r1, r1, lsl #16
mov r12, r1

// load the number of dwords left
lsrs r3, r2, #3

.L_dwordwise:
// dwordwise memset
subs r3, r3, #1
strd r1, r12, [r0], #8
bgt .L_dwordwise

// remaining bytes
ands r2, #7
beq .L_done

.L_bytewise:
// bytewise memset
subs r2, r2, #1
strb r1, [r0], #1
bgt .L_bytewise

.L_done:
// restore the base pointer as return value
pop { r0, pc }

#endif

+ 1
- 1
teensy3/usb_desc.h View File

@@ -252,7 +252,7 @@ let me know? http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports
#define PRODUCT_NAME {'T','e','e','n','s','y','d','u','i','n','o',' ','R','a','w','H','I','D'}
#define PRODUCT_NAME_LEN 18
#define EP0_SIZE 64
#define NUM_ENDPOINTS 6
#define NUM_ENDPOINTS 4
#define NUM_USB_BUFFERS 12
#define NUM_INTERFACE 2
#define RAWHID_INTERFACE 0 // RawHID

Loading…
Cancel
Save