From 51d02f98d6992a8a2db7c8aa20abfbff5cc3a8e3 Mon Sep 17 00:00:00 2001 From: 勤为本 <1207280597@qq.com> Date: Mon, 23 Oct 2017 17:10:48 +0800 Subject: 增加龙芯1c的硬件SPI相关接å�£ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/ls1cdev/libraries/ls1c_public.c | 43 ++++ bsp/ls1cdev/libraries/ls1c_public.h | 11 ++ bsp/ls1cdev/libraries/ls1c_regs.h | 11 ++ bsp/ls1cdev/libraries/ls1c_spi.c | 378 ++++++++++++++++++++++++++++++++++++ bsp/ls1cdev/libraries/ls1c_spi.h | 100 ++++++++++ bsp/ls1cdev/libraries/ls1c_timer.c | 4 +- bsp/ls1cdev/rtconfig.py | 1 + 7 files changed, 546 insertions(+), 2 deletions(-) create mode 100644 bsp/ls1cdev/libraries/ls1c_spi.c create mode 100644 bsp/ls1cdev/libraries/ls1c_spi.h diff --git a/bsp/ls1cdev/libraries/ls1c_public.c b/bsp/ls1cdev/libraries/ls1c_public.c index a04f68a877..3e57e9a50a 100644 --- a/bsp/ls1cdev/libraries/ls1c_public.c +++ b/bsp/ls1cdev/libraries/ls1c_public.c @@ -137,3 +137,46 @@ int ls1c_ffs(int x) } +/* + * fls - find last (most-significant) bit set + * @x: the word to search + * + * This is defined the same way as ffs. + * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. + */ +int ls1c_fls(int x) +{ + int r = 32; + + if (!x) + return 0; + if (!(x & 0xffff0000u)) + { + x <<= 16; + r -= 16; + } + if (!(x & 0xff000000u)) + { + x <<= 8; + r -= 8; + } + if (!(x & 0xf0000000u)) + { + x <<= 4; + r -= 4; + } + if (!(x & 0xc0000000u)) + { + x <<= 2; + r -= 2; + } + if (!(x & 0x80000000u)) + { + x <<= 1; + r -= 1; + } + + return r; +} + + diff --git a/bsp/ls1cdev/libraries/ls1c_public.h b/bsp/ls1cdev/libraries/ls1c_public.h index 34164d8c1c..c06aa4dd8a 100644 --- a/bsp/ls1cdev/libraries/ls1c_public.h +++ b/bsp/ls1cdev/libraries/ls1c_public.h @@ -26,6 +26,8 @@ extern struct callvectors *callvec; #define MIN(a, b) ((a) > (b) ? (b) : (a)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) + typedef enum { FALSE=0, @@ -95,6 +97,15 @@ unsigned int reg_read_32(volatile unsigned int *addr); */ int ls1c_ffs(int x); +/* + * fls - find last (most-significant) bit set + * @x: the word to search + * + * This is defined the same way as ffs. + * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. + */ +int ls1c_fls(int x); + #endif diff --git a/bsp/ls1cdev/libraries/ls1c_regs.h b/bsp/ls1cdev/libraries/ls1c_regs.h index 3d23429865..9d6c21dea6 100644 --- a/bsp/ls1cdev/libraries/ls1c_regs.h +++ b/bsp/ls1cdev/libraries/ls1c_regs.h @@ -117,5 +117,16 @@ #define LS1C_I2C2_BASE (0xbfe70000) +// SPI¼Ä´æÆ÷ +#define LS1C_SPI0_BASE (0xbfe80000) +#define LS1C_SPI1_BASE (0xbfec0000) + + +// ´®¿Ú¼Ä´æÆ÷ +#define LS1C_UART0_BASE (0xbfe40000) +#define LS1C_UART1_BASE (0xbfe44000) +#define LS1C_UART2_BASE (0xbfe48000) + + #endif diff --git a/bsp/ls1cdev/libraries/ls1c_spi.c b/bsp/ls1cdev/libraries/ls1c_spi.c new file mode 100644 index 0000000000..8547626c30 --- /dev/null +++ b/bsp/ls1cdev/libraries/ls1c_spi.c @@ -0,0 +1,378 @@ +/* + * File : ls1c_spi.c + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Change Logs: + * Date Author Notes + * 2017-10-23 ÇÚΪ±¾ first version + */ + +// Ó²¼þspi½Ó¿ÚÔ´Îļþ + + +#include +#include "ls1c_public.h" +#include "ls1c_regs.h" +#include "ls1c_clock.h" +#include "ls1c_spi.h" + + +// ¼Ä´æÆ÷Æ«ÒÆ +#define LS1C_SPI_SPCR_OFFSET (0) // ¿ØÖƼĴæÆ÷ +#define LS1C_SPI_SPSR_OFFSET (1) // ״̬¼Ä´æÆ÷ +#define LS1C_SPI_TxFIFO_OFFSET (2) // ·¢Ë͵ÄÊý¾Ý¼Ä´æÆ÷£¬Óë½ÓÊÕÊý¾Ý¼Ä´æÆ÷µÄÆ«ÒÆÏàͬ +#define LS1C_SPI_RxFIFO_OFFSET (2) // ½ÓÊÕµÄÊý¾Ý¼Ä´æÆ÷£¬Óë·¢ËÍÊý¾Ý¼Ä´æÆ÷µÄÆ«ÒÆÏàͬ +#define LS1C_SPI_SPER_OFFSET (3) // Íⲿ¼Ä´æÆ÷ +#define LS1C_SPI_SFC_PARAM_OFFSET (4) // ²ÎÊý¿ØÖƼĴæÆ÷ +#define LS1C_SPI_SFC_SOFTCS_OFFSET (5) // Ƭѡ¿ØÖƼĴæÆ÷ +#define LS1C_SPI_SFC_TIMING_OFFSET (6) // ʱÐò¿ØÖƼĴæÆ÷ + +// ¼Ä´æÆ÷SPCRÖеÄλÓò +#define LS1C_SPI_SPCR_SPIE_BIT (7) +#define LS1C_SPI_SPCR_SPIE_MASK (0x01 << LS1C_SPI_SPCR_SPIE_BIT) +#define LS1C_SPI_SPCR_SPE_BIT (6) +#define LS1C_SPI_SPCR_SPE_MASK (0x01 << LS1C_SPI_SPCR_SPE_BIT) +#define LS1C_SPI_SPCR_CPOL_BIT (3) +#define LS1C_SPI_SPCR_CPOL_MASK (0x01 << LS1C_SPI_SPCR_CPOL_BIT) +#define LS1C_SPI_SPCR_CPHA_BIT (2) +#define LS1C_SPI_SPCR_CPHA_MASK (0x01 << LS1C_SPI_SPCR_CPHA_BIT) +#define LS1C_SPI_SPCR_SPR_BIT (0) +#define LS1C_SPI_SPCR_SPR_MASK (0x03 << LS1C_SPI_SPCR_SPR_BIT) + +// ¼Ä´æÆ÷SPSRÖеÄλÓò +#define LS1C_SPI_SPSR_SPIF_BIT (7) +#define LS1C_SPI_SPSR_SPIF_MASK (0x01 << LS1C_SPI_SPSR_SPIF_BIT) +#define LS1C_SPI_SPSR_WCOL_BIT (6) +#define LS1C_SPI_SPSR_WCOL_MASK (0x01 << LS1C_SPI_SPSR_WCOL_BIT) + +// ¼Ä´æÆ÷SPERÖеÄλÓò +#define LS1C_SPI_SPER_SPRE_BIT (0) +#define LS1C_SPI_SPER_SPRE_MASK (0x3 << LS1C_SPI_SPER_SPRE_BIT) + +// ¼Ä´æÆ÷SFC_SOFTCSµÄλÓò +#define LS1C_SPI_SFC_SOFTCS_CSN_BIT (4) +#define LS1C_SPI_SFC_SOFTCS_CSN_MASK (0x0f << LS1C_SPI_SFC_SOFTCS_CSN_BIT) +#define LS1C_SPI_SFC_SOFTCS_CSEN_BIT (0) +#define LS1C_SPI_SFC_SOFTCS_CSEN_MASK (0x0f << LS1C_SPI_SFC_SOFTCS_CSEN_BIT) + +// ·¢Ëͳ¬Ê±µÄÃÅÏÞÖµ +#define LS1C_SPI_TX_TIMEOUT (20000) + + +/* + * »ñȡָ¶¨SPIÄ£¿éµÄ»ùµØÖ· + * @SPIx SPIÄ£¿éµÄ±àºÅ + */ +inline void *spi_get_base(ls1c_spi_t SPIx) +{ + void *base = NULL; + + switch (SPIx) + { + case LS1C_SPI_0: + base = (void *)LS1C_SPI0_BASE; + break; + + case LS1C_SPI_1: + base = (void *)LS1C_SPI1_BASE; + break; + + default: + base = NULL; + break; + } + + return base; +} + + +/* + * ´òÓ¡Ö¸¶¨SPIÄ£¿éµÄËùÓмĴæÆ÷µÄÖµ + * @spi_info_p SPIÄ£¿éÐÅÏ¢ + */ +void spi_print_all_regs_info(ls1c_spi_info_t *spi_info_p) +{ + void *spi_base = spi_get_base(spi_info_p->SPIx); + + rt_kprintf("[%s] SPI%d's info:\r\n\ + SPCR=0x%x, SPSR=0x%x, SPER=0x%x, SFC_PARAM=0x%x, SFC_SOFTCS=0x%x, SFC_TIMING=0x%x\r\n", + __FUNCTION__, spi_info_p->SPIx, + reg_read_8(spi_base + LS1C_SPI_SPCR_OFFSET), + reg_read_8(spi_base + LS1C_SPI_SPSR_OFFSET), + reg_read_8(spi_base + LS1C_SPI_SPER_OFFSET), + reg_read_8(spi_base + LS1C_SPI_SFC_PARAM_OFFSET), + reg_read_8(spi_base + LS1C_SPI_SFC_SOFTCS_OFFSET), + reg_read_8(spi_base + LS1C_SPI_SFC_TIMING_OFFSET)); + + return ; +} + + +/* + * ¸ù¾ÝSPIʱÖÓÆµÂʼÆËã·ÖƵϵÊý + * @max_speed_hz SPI×î´óͨÐÅËÙ¶È + * @ret ·ÖƵϵÊý + */ +unsigned int spi_get_div(unsigned int max_speed_hz) +{ + unsigned long clk = 0; + unsigned int div = 0; + unsigned int div_tmp = 0; + unsigned int bit = 0; + + clk = clk_get_apb_rate(); + div = DIV_ROUND_UP(clk, max_speed_hz); + + if (div < 2) + div = 2; + + if (div > 4096) + div = 4096; + + bit = ls1c_fls(div) - 1; + switch (1 << bit) + { + case 16: + div_tmp = 2; + if (div > (1 << bit)) + { + div_tmp++; + } + break; + + case 32: + div_tmp = 3; + if (div > (1 << bit)) + { + div_tmp += 2; + } + break; + + case 8: + div_tmp = 4; + if (div > (1 << bit)) + { + div_tmp -= 2; + } + break; + + default: + div_tmp = bit - 1; + if (div > (1 << bit)) + { + div_tmp++; + } + break; + } +/* + rt_kprintf("[%s] clk=%ld, max_speed_hz=%d, div_tmp=%d, bit=%d\r\n", + __FUNCTION__, clk, max_speed_hz, div_tmp, bit); +*/ + return div_tmp; +} + + +/* + * ÉèÖÃʱÖÓ + * @spi_info_p SPIÄ£¿éÐÅÏ¢ + */ +void spi_set_clock(ls1c_spi_info_t *spi_info_p) +{ + void *spi_base = spi_get_base(spi_info_p->SPIx); + unsigned int div = 0; + unsigned char val = 0; + + // »ñÈ¡·ÖƵϵÊý + div = spi_get_div(spi_info_p->max_speed_hz); + + // ÉèÖÃspr + val = reg_read_8(spi_base + LS1C_SPI_SPCR_OFFSET); + val &= (~LS1C_SPI_SPCR_SPR_MASK); // sprÇåÁã + val |= (div & LS1C_SPI_SPCR_SPR_MASK); // ÉèÖÃеÄspr + reg_write_8(val, spi_base + LS1C_SPI_SPCR_OFFSET); + + // ÉèÖÃspre + val = reg_read_8(spi_base + LS1C_SPI_SPER_OFFSET); + val &= (~LS1C_SPI_SPER_SPRE_MASK); // spreÇåÁã + val |= ((div >> 2) & LS1C_SPI_SPER_SPRE_MASK); // ÉèÖÃеÄspre + reg_write_8(val, spi_base + LS1C_SPI_SPER_OFFSET); + + return ; +} + + +/* + * ÉèÖÃͨÐÅģʽ(ʱÖÓ¼«ÐÔºÍÏàλ) + * @spi_info_p SPIÄ£¿éÐÅÏ¢ + */ +void spi_set_mode(ls1c_spi_info_t *spi_info_p) +{ + void *spi_base = spi_get_base(spi_info_p->SPIx); + unsigned char val = 0; + + val = reg_read_8(spi_base + LS1C_SPI_SPCR_OFFSET); + + // ÉèÖÃʱÖÓ¼«ÐÔ--cpol + val &= (~LS1C_SPI_SPCR_CPOL_MASK); // cpolÇå0 + val |= (spi_info_p->cpol << LS1C_SPI_SPCR_CPOL_BIT); // дÈëеÄcpol + + // ÉèÖÃʱÖÓÏàλ--cpha + val &= (~LS1C_SPI_SPCR_CPHA_MASK); // cphaÇå0 + val |= (spi_info_p->cpha << LS1C_SPI_SPCR_CPHA_BIT); // дÈëеÄcpha + + reg_write_8(val, spi_base + LS1C_SPI_SPCR_OFFSET); + + return ; +} + + +/* + * ÉèÖÃÖ¸¶¨Æ¬Ñ¡ÎªÖ¸¶¨×´Ì¬ + * @spi_info_p SPIÄ£¿éÐÅÏ¢ + * @new_status ƬѡÒý½ÅµÄÐÂ״̬£¬È¡ÖµÎª0»ò1£¬¼´¸ßµçƽ»òµÍµçƽ + */ +void spi_set_cs(ls1c_spi_info_t *spi_info_p, int new_status) +{ + void *spi_base = spi_get_base(spi_info_p->SPIx); + unsigned char cs = spi_info_p->cs; + unsigned char val = 0; + + val = 0xf0 | (0x01 << cs); // È«²¿csn=1£¬Ö¸¶¨µÄcsen=1 + if (new_status) // cs = 1 + { + val |= (0x10 << cs); // Ö¸¶¨csn=1 + } + else // cs = 0 + { + val &= ~(0x10 << cs); // Ö¸¶¨csn=0 + } + reg_write_8(val, spi_base + LS1C_SPI_SFC_SOFTCS_OFFSET); + + return ; +} + + +/* + * ³õʼ»¯Ö¸¶¨SPIÄ£¿é + * @spi_info_p SPIÄ£¿éÐÅÏ¢ + */ +void spi_init(ls1c_spi_info_t *spi_info_p) +{ + void *spi_base = spi_get_base(spi_info_p->SPIx); + unsigned char val = 0; + + // ʹÄÜSPI¿ØÖÆÆ÷£¬masterģʽ£¬¹Ø±ÕÖÐ¶Ï + reg_write_8(0x53, spi_base + LS1C_SPI_SPCR_OFFSET); + + // Çå¿Õ״̬¼Ä´æÆ÷ + reg_write_8(0xc0, spi_base + LS1C_SPI_SPSR_OFFSET); + + // 1×Ö½Ú²úÉúÖжϣ¬²ÉÑù(¶Á)Óë·¢ËÍ(д)ʱ»úͬʱ + reg_write_8(0x03, spi_base + LS1C_SPI_SPER_OFFSET); + + // ¹Ø±ÕSPI flash + val = reg_read_8(spi_base + LS1C_SPI_SFC_PARAM_OFFSET); + val &= 0xfe; + reg_write_8(val, spi_base + LS1C_SPI_SFC_PARAM_OFFSET); + + // spi flashʱÐò¿ØÖƼĴæÆ÷ + reg_write_8(0x05, spi_base + LS1C_SPI_SFC_TIMING_OFFSET); + + // ÉèÖÃʱÖÓ + spi_set_clock(spi_info_p); + + // ÉèÖÃͨÐÅģʽ(ʱÖÓ¼«ÐÔºÍÏàλ) + spi_set_mode(spi_info_p); + + // ´òÓ¡¼Ä´æÆ÷ÐÅÏ¢(ÓÃÓÚµ÷ÊÔ) +// spi_print_all_regs_info(spi_info_p); + + return ; +} + + +/* + * µÈ´ýÊÕ·¢Íê³É + */ +inline void spi_wait_txrx_done(ls1c_spi_info_t *spi_info_p) +{ + void *spi_base = spi_get_base(spi_info_p->SPIx); + int timeout = LS1C_SPI_TX_TIMEOUT; + + while (timeout--) + { + if (LS1C_SPI_SPSR_SPIF_MASK & reg_read_8(spi_base + LS1C_SPI_SPSR_OFFSET)) + break; + } + + return ; +} + + +/* + * ÇåÖжϺͱê־λ + */ +inline void spi_clear(ls1c_spi_info_t *spi_info_p) +{ + void *spi_base = spi_get_base(spi_info_p->SPIx); + unsigned char val = 0; + + // ÇåÖÐ¶Ï + val = reg_read_8(spi_base + LS1C_SPI_SPSR_OFFSET); + val |= LS1C_SPI_SPSR_SPIF_MASK; + reg_write_8(val, spi_base + LS1C_SPI_SPSR_OFFSET); + + // ÇåÒç³ö±ê־λ(Write-Collision Clear) + val = reg_read_8(spi_base + LS1C_SPI_SPSR_OFFSET); + if (LS1C_SPI_SPSR_WCOL_MASK & val) + { + rt_kprintf("[%s] clear register SPSR's wcol!\r\n"); // ÊÖ²áºÍlinuxÔ´ÂëÖв»Ò»Ñù£¬¼Ó¸ö´òÓ¡¿´¿´ + reg_write_8(val & ~LS1C_SPI_SPSR_WCOL_MASK, spi_base + LS1C_SPI_SPSR_OFFSET); // д0£¬linuxÔ´ÂëÖÐÊÇд0 +// reg_write_8(val | LS1C_SPI_SPSR_WCOL_MASK, spi_base + LS1C_SPI_SPSR_OFFSET); // д1£¬°´ÕÕ1cÊֲᣬӦ¸Ãд1 + } + + return ; +} + + + +/* + * ͨ¹ýÖ¸¶¨SPI·¢ËͽÓÊÕÒ»¸ö×Ö½Ú + * ×¢Ò⣬ÔÚ¶àÈÎÎñµÄϵͳÖУ¬´Ëº¯ÊýÐèÒª»¥³â¡£ + * ¼´±£Ö¤ÔÚºÍij¸ö´ÓÉ豸ÊÕ·¢Ä³¸ö×ֽڵĹý³ÌÖУ¬²»Äܱ»Çл»µ½ÆäËüÈÎÎñͬʱÓëÁíÍâµÄÔÚͬһ¸öSPI×ÜÏßÉϵĴÓÉ豸ͨÐÅ + * ÒòΪÁúо1cµÄÿ·SPIÉÏ¿ÉÄܽÓÓв»Í¬µÄ´ÓÉ豸£¬Í¨ÐÅÆµÂÊ¡¢Ä£Ê½µÈ¿ÉÄܲ»Í¬ + * @spi_info_p SPI½Ó¿Ú + * @tx_ch ´ý·¢Ë͵ÄÊý¾Ý + * @ret ÊÕµ½µÄÊý¾Ý + */ +unsigned char spi_txrx_byte(ls1c_spi_info_t *spi_info_p, unsigned char tx_ch) +{ + void *spi_base = spi_get_base(spi_info_p->SPIx); + unsigned char rx_ch = 0; + + // ÊÕ·¢Êý¾Ý + reg_write_8(tx_ch, spi_base + LS1C_SPI_TxFIFO_OFFSET); // ¿ªÊ¼·¢ËÍ + spi_wait_txrx_done(spi_info_p); // µÈ´ýÊÕ·¢Íê³É + rx_ch = reg_read_8(spi_base + LS1C_SPI_RxFIFO_OFFSET); // ¶ÁÈ¡ÊÕµ½µÄÊý¾Ý + spi_clear(spi_info_p); // ÇåÖжϺͱê־λ + + return rx_ch; +} + + + diff --git a/bsp/ls1cdev/libraries/ls1c_spi.h b/bsp/ls1cdev/libraries/ls1c_spi.h new file mode 100644 index 0000000000..6b041b19c1 --- /dev/null +++ b/bsp/ls1cdev/libraries/ls1c_spi.h @@ -0,0 +1,100 @@ +/* + * File : ls1c_spi.h + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Change Logs: + * Date Author Notes + * 2017-10-23 ÇÚΪ±¾ first version + */ + +// Ó²¼þspi½Ó¿ÚµÄÍ·Îļþ + +#ifndef __OPENLOONGSON_SPI_H +#define __OPENLOONGSON_SPI_H + + +// SPIÄ£¿é±àºÅ +typedef enum +{ + LS1C_SPI_0 = 0, + LS1C_SPI_1, +}ls1c_spi_t; + + +// Ƭѡ +#define LS1C_SPI_INVALID_CS (-1) +#define LS1C_SPI_CS_0 (0) +#define LS1C_SPI_CS_1 (1) +#define LS1C_SPI_CS_2 (2) +#define LS1C_SPI_CS_3 (3) + +// ʱÖÓ¼«ÐÔºÍÏàλ +#define SPI_CPOL_1 (1) +#define SPI_CPOL_0 (0) +#define SPI_CPHA_1 (1) +#define SPI_CPHA_0 (0) + + +// Ó²¼þSPIÐÅÏ¢ +typedef struct +{ + ls1c_spi_t SPIx; // SPIÄ£¿é±àºÅ + unsigned long max_speed_hz; // ×î´óͨÐÅËÙ¶È£¬µ¥Î»hz + unsigned char cs; // Ƭѡ + unsigned char cpol; // ʱÖÓ¼«ÐÔ + unsigned char cpha; // ʱÖÓÏàλ +}ls1c_spi_info_t; + + + +/* + * ³õʼ»¯Ö¸¶¨SPIÄ£¿é + * @spi_info_p SPIÄ£¿éÐÅÏ¢ + */ +void spi_init(ls1c_spi_info_t *spi_info_p); + + +/* + * ÉèÖÃÖ¸¶¨Æ¬Ñ¡ÎªÖ¸¶¨×´Ì¬ + * @spi_info_p SPIÄ£¿éÐÅÏ¢ + * @new_status ƬѡÒý½ÅµÄÐÂ״̬£¬È¡ÖµÎª0»ò1£¬¼´¸ßµçƽ»òµÍµçƽ + */ +void spi_set_cs(ls1c_spi_info_t *spi_info_p, int new_status); + + +/* + * ͨ¹ýÖ¸¶¨SPI·¢ËͽÓÊÕÒ»¸ö×Ö½Ú + * ×¢Ò⣬ÔÚ¶àÈÎÎñµÄϵͳÖУ¬´Ëº¯ÊýÐèÒª»¥³â¡£ + * ¼´±£Ö¤ÔÚºÍij¸ö´ÓÉ豸ÊÕ·¢Ä³¸ö×ֽڵĹý³ÌÖУ¬²»Äܱ»Çл»µ½ÆäËüÈÎÎñͬʱÓëÁíÍâµÄÔÚͬһ¸öSPI×ÜÏßÉϵĴÓÉ豸ͨÐÅ + * ÒòΪÁúо1cµÄÿ·SPIÉÏ¿ÉÄܽÓÓв»Í¬µÄ´ÓÉ豸£¬Í¨ÐÅÆµÂÊ¡¢Ä£Ê½µÈ¿ÉÄܲ»Í¬ + * @spi_info_p SPI½Ó¿Ú + * @tx_ch ´ý·¢Ë͵ÄÊý¾Ý + * @ret ÊÕµ½µÄÊý¾Ý + */ +unsigned char spi_txrx_byte(ls1c_spi_info_t *spi_info_p, unsigned char tx_ch); + + +/* + * ´òÓ¡Ö¸¶¨SPIÄ£¿éµÄËùÓмĴæÆ÷µÄÖµ + * @spi_info_p SPIÄ£¿éÐÅÏ¢ + */ +void spi_print_all_regs_info(ls1c_spi_info_t *spi_info_p); + + +#endif + diff --git a/bsp/ls1cdev/libraries/ls1c_timer.c b/bsp/ls1cdev/libraries/ls1c_timer.c index 8c3b164121..0075e6e3f6 100644 --- a/bsp/ls1cdev/libraries/ls1c_timer.c +++ b/bsp/ls1cdev/libraries/ls1c_timer.c @@ -172,7 +172,7 @@ unsigned long timer_get_time_ns(timer_info_t *timer_info) */ timer_clk = clk_get_apb_rate(); time_ns = (cntr * 1000 ) / (timer_clk /1000000); -// myprintf("[%s] time_us=%lu, cntr=%d, timer_clk=%d\n", __FUNCTION__, time_ns, cntr, timer_clk); +// rt_kprintf("[%s] time_us=%lu, cntr=%d, timer_clk=%d\n", __FUNCTION__, time_ns, cntr, timer_clk); return time_ns; } @@ -188,7 +188,7 @@ void timer_print_regs(timer_info_t *timer_info) unsigned int timer_reg_base = 0; timer_reg_base = timer_get_reg_base(timer_info->timer); - myprintf("CNTR=0x%x, HRC=0x%x, LRC=0x%x, CTRL=0x%x\n", + rt_kprintf("CNTR=0x%x, HRC=0x%x, LRC=0x%x, CTRL=0x%x\n", reg_read_32((volatile unsigned int *)(timer_reg_base + LS1C_PWM_CNTR)), reg_read_32((volatile unsigned int *)(timer_reg_base + LS1C_PWM_HRC)), reg_read_32((volatile unsigned int *)(timer_reg_base + LS1C_PWM_LRC)), diff --git a/bsp/ls1cdev/rtconfig.py b/bsp/ls1cdev/rtconfig.py index df0f57d78d..c08dfc6852 100644 --- a/bsp/ls1cdev/rtconfig.py +++ b/bsp/ls1cdev/rtconfig.py @@ -12,6 +12,7 @@ if os.getenv('RTT_CC'): if CROSS_TOOL == 'gcc': PLATFORM = 'gcc' +# EXEC_PATH = "/opt/mips-2015.05/bin" EXEC_PATH = r'D:\mgc\embedded\codebench\bin' else: print '================ERROR===========================' -- cgit v1.3.1