使用USI作为主SPI接口

代码;

lcd_drive.c

//*****************************************************************************
//
//  File........: LCD_driver.c
//
//  Author(s)...: ATMEL Norway
//
//  Target(s)...: ATmega169
//
//  Compiler....: AVR-GCC 3.3.1; avr-libc 1.0
//
//  Description.: Functions used to control the AVR Butterfly LCD
//
//  Revisions...: 1.0
//
//  YYYYMMDD - VER. - COMMENT                                       - SIGN.
//
//  20021015 - 1.0  - Written for STK502                            - JLL
//  20030116 - 2.0  - Code adapted to AVR Butterfly                 - KS
//  20031009          port to avr-gcc/avr-libc                      - M.Thomas
//
//*****************************************************************************

#define REDUCED

// Include files.
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <inttypes.h>
#include <avr/interrupt.h>
#include <avr/interrupt.h>



// mt - for gButtonTimeout
// #include "button.h"

#include "LCD_driver.h"

#ifndef BOOL
#define BOOL    char
#define FALSE   0
#define TRUE    (!FALSE)
#endif

// Variable from "button.c" to prevent button-bouncing
extern unsigned char gButtonTimeout;    

volatile char gAutoPressJoystick = FALSE;

// Used to indicate when the LCD interrupt handler should update the LCD
// mt jw char gLCD_Update_Required = FALSE;
volatile char gLCD_Update_Required = FALSE;

// LCD display buffer (for double buffering).
volatile char LCD_Data[LCD_REGISTER_COUNT];

// Buffer that contains the text to be displayed
// Note: Bit 7 indicates that this character is flashing
volatile char gTextBuffer[TEXTBUFFER_SIZE];

// Only six letters can be shown on the LCD.
// With the gScroll and gScrollMode variables,
// one can select which part of the buffer to show
volatile signed char gScroll;
volatile char gScrollMode;

Start-up delay before scrolling a string over the LCD
char gLCD_Start_Scroll_Timer = 0;

// The gFlashTimer is used to determine the on/off
// timing of flashing characters
volatile char gFlashTimer = 0;

// Turns on/off the colons on the LCD
char gColon = 0;


// Look-up table used when converting ASCII to
// LCD display data (segment control)
// mt __flash unsigned int LCD_character_table[] =
unsigned int LCD_character_table[] PROGMEM =
{
    0x0A51,     // '*' (?)
    0x2A80,     // '+'
    0x0000,     // ',' (Not defined)
    0x0A00,     // '-'
    0x0A51,     // '.' Degree sign
    0x0000,     // '/' (Not defined)
    0x5559,     // '0'
    0x0118,     // '1'
    0x1e11,     // '2
    0x1b11,     // '3
    0x0b50,     // '4
    0x1b41,     // '5
    0x1f41,     // '6
    0x0111,     // '7
    0x1f51,     // '8
    0x1b51,     // '9'
    0x0000,     // ':' (Not defined)
    0x0000,     // ';' (Not defined)
    0x0000,     // '<' (Not defined)
    0x0000,     // '=' (Not defined)
    0x0000,     // '>' (Not defined)
    0x0000,     // '?' (Not defined)
    0x0000,     // '@' (Not defined)
    0x0f51,     // 'A' (+ 'a')
    0x3991,     // 'B' (+ 'b')
    0x1441,     // 'C' (+ 'c')
    0x3191,     // 'D' (+ 'd')
    0x1e41,     // 'E' (+ 'e')
    0x0e41,     // 'F' (+ 'f')
    0x1d41,     // 'G' (+ 'g')
    0x0f50,     // 'H' (+ 'h')
    0x2080,     // 'I' (+ 'i')
    0x1510,     // 'J' (+ 'j')
    0x8648,     // 'K' (+ 'k')
    0x1440,     // 'L' (+ 'l')
    0x0578,     // 'M' (+ 'm')
    0x8570,     // 'N' (+ 'n')
    0x1551,     // 'O' (+ 'o')
    0x0e51,     // 'P' (+ 'p')
    0x9551,     // 'Q' (+ 'q')
    0x8e51,     // 'R' (+ 'r')
    0x9021,     // 'S' (+ 's')
    0x2081,     // 'T' (+ 't')
    0x1550,     // 'U' (+ 'u')
    0x4448,     // 'V' (+ 'v')
    0xc550,     // 'W' (+ 'w')
    0xc028,     // 'X' (+ 'x')
    0x2028,     // 'Y' (+ 'y')
    0x5009,     // 'Z' (+ 'z')
    0x0000,     // '[' (Not defined)
    0x0000,     // '\' (Not defined)
    0x0000,     // ']' (Not defined)
    0x0000,     // '^' (Not defined)
    0x0000      // '_'
};


/*****************************************************************************
*
*   Function name : LCD_Init
*
*   Returns :       None
*
*   Parameters :    None
*
*   Purpose :       Initialize LCD_displayData buffer.
*                   Set up the LCD (timing, contrast, etc.)
*
*****************************************************************************/
void LCD_Init (void)
{
    LCD_AllSegments(FALSE);                     // Clear segment buffer.

    LCD_CONTRAST_LEVEL(LCD_INITIAL_CONTRAST);    //Set the LCD contrast level

    // Select asynchronous clock source, enable all COM pins and enable all
    // segment pins.
    LCDCRB = (1<<LCDCS) | (3<<LCDMUX0) | (7<<LCDPM0);

    // Set LCD prescaler to give a framerate of 32,0 Hz
    LCDFRR = (0<<LCDPS0) | (7<<LCDCD0);    

    LCDCRA = (1<<LCDEN) | (1<<LCDAB);           // Enable LCD and set low power waveform

    //Enable LCD start of frame interrupt
    LCDCRA |= (1<<LCDIE);

    gLCD_Update_Required = FALSE;


}


/*****************************************************************************
*
*   Function name : LCD_WriteDigit(char c, char digit)
*
*   Returns :       None
*
*   Parameters :    Inputs
*                   c: The symbol to be displayed in a LCD digit
*                   digit: In which digit (0-5) the symbol should be displayed
*                   Note: Digit 0 is the first used digit on the LCD,
*                   i.e LCD digit 2
*
*   Purpose :       Stores LCD control data in the LCD_displayData buffer.
*                   (The LCD_displayData is latched in the LCD_SOF interrupt.)
*
*****************************************************************************/
void LCD_WriteDigit(char c, char digit)
{

    unsigned int seg = 0x0000;                  // Holds the segment pattern
    char mask, nibble;
    volatile char *ptr;
    char i;


    if (digit > 5)                              // Skip if digit is illegal
        return;

    //Lookup character table for segmet data
    if ((c >= '*') && (c <= 'z'))
    {
        // c is a letter
        if (c >= 'a')                           // Convert to upper case
            c &= ~0x20;                         // if necessarry

        c -= '*';

		//mt seg = LCD_character_table[c];
		seg = (unsigned int) pgm_read_word(&LCD_character_table[(uint8_t)c]); 
	}

    // Adjust mask according to LCD segment mapping
    if (digit & 0x01)
        mask = 0x0F;                // Digit 1, 3, 5
    else
        mask = 0xF0;                // Digit 0, 2, 4

    ptr = LCD_Data + (digit >> 1);  // digit = {0,0,1,1,2,2}

    for (i = 0; i < 4; i++)
    {
        nibble = seg & 0x000F;
        seg >>= 4;
        if (digit & 0x01)
            nibble <<= 4;
        *ptr = (*ptr & mask) | nibble;
        ptr += 5;
    }
}



/*****************************************************************************
*
*   Function name : LCD_AllSegments(unsigned char input)
*
*   Returns :       None
*
*   Parameters :    show -  [TRUE;FALSE]
*
*   Purpose :       shows or hide all all LCD segments on the LCD
*
*****************************************************************************/
void LCD_AllSegments(char show)
{
    unsigned char i;

    if (show)
        show = 0xFF;

    // Set/clear all bits in all LCD registers
    for (i=0; i < LCD_REGISTER_COUNT; i++)
        *(LCD_Data + i) = show;
}


/*****************************************************************************
*
*   LCD Interrupt Routine
*
*   Returns :       None
*
*   Parameters :    None
*
*   Purpose: Latch the LCD_displayData and Set LCD_status.updateComplete
*
*****************************************************************************/

SIGNAL(SIG_LCD)
{
    static char LCD_timer = LCD_TIMER_SEED;
    char c;
    char c_flash;
    char flash;

    char EOL;
    unsigned char i;

#ifndef REDUCED
    static char timeout_count;
    static char auto_joystick_count;
#endif
	
	c_flash=0; // mt

#ifndef REDUCED
/**************** Button timeout for the button.c, START ****************/
    if(!gButtonTimeout)
    {
        timeout_count++;
        
        if(timeout_count > 3)
        {
            gButtonTimeout = TRUE;
            timeout_count = 0;
        }
    }

/**************** Button timeout for the button.c, END ******************/

/**************** Auto press joystick for the main.c, START *************/

    if(gAutoPressJoystick == AUTO)
    {
        auto_joystick_count++;
        
        if(auto_joystick_count > 16)
        {
            gAutoPressJoystick = TRUE;
            auto_joystick_count = 15;
        }
    }
    else
        auto_joystick_count = 0;


/**************** Auto press joystick for the main.c, END ***************/    
#endif

    LCD_timer--;                    // Decreased every LCD frame

    if (gScrollMode)
    {
        // If we are in scroll mode, and the timer has expired,
        // we will update the LCD
        if (LCD_timer == 0)
        {
            if (gLCD_Start_Scroll_Timer == 0)
            {
                gLCD_Update_Required = TRUE;
            }
            else
                gLCD_Start_Scroll_Timer--;
        }
    }
    else    
    {   // if not scrolling,
        // disble LCD start of frame interrupt
//        cbi(LCDCRA, LCDIE);   //DEBUG
        gScroll = 0;
    }


    EOL = FALSE;
    if (gLCD_Update_Required == TRUE)
    {
        // Duty cycle of flashing characters
        if (gFlashTimer < (LCD_FLASH_SEED >> 1))
            flash = 0;
        else
            flash = 1;

        // Repeat for the six LCD characters
        for (i = 0; i < 6; i++)
        {
            if ((gScroll+i) >= 0 && (!EOL))
            {
                // We have some visible characters
                c = gTextBuffer[i + gScroll];
                c_flash = c & 0x80 ? 1 : 0;
                c = c & 0x7F;

                if (c == '\0')
                    EOL = i+1;      // End of character data
            }
            else
                c = ' ';

            // Check if this character is flashing

            if (c_flash && flash)
                LCD_WriteDigit(' ', i);
            else
                LCD_WriteDigit(c, i);
        }

        // Copy the segment buffer to the real segments
        for (i = 0; i < LCD_REGISTER_COUNT; i++)
            *(pLCDREG + i) = *(LCD_Data+i);

        // Handle colon
        if (gColon)
            *(pLCDREG + 8) = 0x01;
        else
            *(pLCDREG + 8) = 0x00;

        // If the text scrolled off the display,
        // we have to start over again.
        if (EOL == 1)
            gScroll = -6;
        else
            gScroll++;

        // No need to update anymore
        gLCD_Update_Required = FALSE;
    }


    // LCD_timer is used when scrolling text
    if (LCD_timer == 0)
    {
/*        if ((gScroll <= 0) || EOL)
            LCD_timer = LCD_TIMER_SEED/2;
        else*/
            LCD_timer = LCD_TIMER_SEED;
    }

    // gFlashTimer is used when flashing characters
    if (gFlashTimer == LCD_FLASH_SEED)
        gFlashTimer= 0;
    else
        gFlashTimer++;

}

lcd_functions.c

//*****************************************************************************
//
//  File........: LCD_functions.c
//
//  Author(s)...: ATMEL Norway
//
//  Target(s)...: ATmega169
//
//  Compiler....: AVR-GCC 3.3.1; avr-libc 1.0
//
//  Description.: Additional LCD functions, scrolling text and write data
//
//  Revisions...: 1.0
//
//  YYYYMMDD - VER. - COMMENT                                       - SIGN.
//
//  20021015 - 1.0  - Created                                       - LHM
//  20030116 - 2.0  - Code adapted to AVR Butterflyup               - KS
//  20031009          port to avr-gcc/avr-libc                      - M.Thomas
//
//*****************************************************************************

#define REDUCED

//  Include files
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <inttypes.h>
#include "LCD_driver.h"
#include "LCD_functions.h"

#ifndef REDUCED
#include "BCD.h"
// mt only for KEY_* and ST_OPTIONS_DISPLAY* definitions:
#include "main.h"
#endif

#define FALSE   0
#define TRUE    (!FALSE)

// mt char CONTRAST = LCD_INITIAL_CONTRAST;
uint8_t CONTRAST = LCD_INITIAL_CONTRAST;

// Start-up delay before scrolling a string over the LCD. "LCD_driver.c"
extern char gLCD_Start_Scroll_Timer;

/****************************************************************************
*
*	Function name : LCD_puts_f
*
*	Returns :		None
*
*	Parameters :	pFlashStr: Pointer to the string in flash
*                   scrollmode: Not in use
*
*	Purpose :		Writes a string stored in flash to the LCD
*
*****************************************************************************/

// mt void LCD_puts_f(char __flash *pFlashStr, char scrollmode)
void LCD_puts_f(const char *pFlashStr, char scrollmode)
{
    // char i;
	uint8_t i;

    while (gLCD_Update_Required);      // Wait for access to buffer

    // mt: for (i = 0; pFlashStr[i] && i < TEXTBUFFER_SIZE; i++)
	for (i = 0; (const char)(pgm_read_byte(&pFlashStr[i])) && i < TEXTBUFFER_SIZE; i++)
    {
        // mt: gTextBuffer[i] = pFlashStr[i];
		gTextBuffer[i] = pgm_read_byte(&pFlashStr[i]);
    }

    gTextBuffer[i] = '\0';

    if (i > 6)
    {
        gScrollMode = 1;        // Scroll if text is longer than display size
        gScroll = 0;
        gLCD_Start_Scroll_Timer = 3;    //Start-up delay before scrolling the text
    }
    else
    {
        gScrollMode = 0;        
        gScroll = 0;
    }

    gLCD_Update_Required = 1;
}


/****************************************************************************
*
*	Function name : LCD_puts
*
*	Returns :		None
*
*	Parameters :	pStr: Pointer to the string
*                   scrollmode: Not in use
*
*	Purpose :		Writes a string to the LCD
*
*****************************************************************************/
void LCD_puts(char *pStr, char scrollmode)
{
	uint8_t i; // char i;
	
	while (gLCD_Update_Required);      // Wait for access to buffer

    for (i = 0; pStr[i] && i < TEXTBUFFER_SIZE; i++)
    {
        gTextBuffer[i] = pStr[i];
    }

    gTextBuffer[i] = '\0';

    if (i > 6)
    {
        gScrollMode = 1;        // Scroll if text is longer than display size
        gScroll = 0;
        gLCD_Start_Scroll_Timer = 3;    //Start-up delay before scrolling the text
    }
    else
    {
        gScrollMode = 0;        
        gScroll = 0;
    }

    gLCD_Update_Required = 1;
}


/****************************************************************************
*
*	Function name : LCD_putc
*
*	Returns :		None
*
*	Parameters :	digit: Which digit to write on the LCD
*                   character: Character to write
*
*	Purpose :		Writes a character to the LCD
*
*****************************************************************************/
// mt void LCD_putc(char digit, char character)
void LCD_putc(uint8_t digit, char character)
{
    if (digit < TEXTBUFFER_SIZE)
        gTextBuffer[digit] = character;
}


/****************************************************************************
*
*	Function name : LCD_Clear
*
*	Returns :		None
*
*	Parameters :	None
*
*	Purpose :		Clear the LCD
*
*****************************************************************************/
void LCD_Clear(void)
{
    uint8_t i; // char i;
	   
    for (i=0; i<TEXTBUFFER_SIZE; i++)
        gTextBuffer[i] = ' ';
}


/****************************************************************************
*
*	Function name : LCD_Colon
*
*	Returns :		None
*
*	Parameters :	show: Enables the colon if TRUE, disable if FALSE
*
*	Purpose :		Enable/disable colons on the LCD
*
*****************************************************************************/
void LCD_Colon(char show)
{
    gColon = show;
}


/****************************************************************************
*
*	Function name : LCD_UpdateRequired
*
*	Returns :		None
*
*	Parameters :	update: TRUE/FALSE
*                   scrollmode: not in use
*
*	Purpose :		Tells the LCD that there is new data to be presented
*
*****************************************************************************/
void LCD_UpdateRequired(char update, char scrollmode)
{

    while (gLCD_Update_Required);
    
    gScrollMode = scrollmode;
    gScroll = 0;

    gLCD_Update_Required = update;
}


/****************************************************************************
*
*	Function name : LCD_FlashReset
*
*	Returns :		None
*
*	Parameters :	None
*
*	Purpose :		This function resets the blinking cycle of a flashing digit
*
*****************************************************************************/
void LCD_FlashReset(void)
{
    gFlashTimer = 0;
}


#ifndef REDUCED

/****************************************************************************
*
*	Function name : SetContrast
*
*   Returns :       char ST_state (to the state-machine)
*
*   Parameters :    char input (from joystick)
*
*	Purpose :		Adjust the LCD contrast
*
*****************************************************************************/
char SetContrast(char input)
{
    static char enter = 1;
    char CH, CL;

    if (enter)
    {
        LCD_Clear();
        enter = 0;
    }

    CH = CHAR2BCD2(CONTRAST);
    CL = (CH & 0x0F) + '0';
    CH = (CH >> 4) + '0';

    LCD_putc(0, 'C');
    LCD_putc(1, 'T');
    LCD_putc(2, 'R');
    LCD_putc(3, ' ');
    LCD_putc(4, CH);
    LCD_putc(5, CL);

    LCD_UpdateRequired(TRUE, 0);

    if (input == KEY_PLUS)
        CONTRAST++;
    else if (input == KEY_MINUS)
        CONTRAST--;

    if (CONTRAST == 255)
        CONTRAST = 0;
    if (CONTRAST > 15)
        CONTRAST = 15;

    LCD_CONTRAST_LEVEL(CONTRAST);


    if (input == KEY_ENTER)
    {
        enter = 1;
        return ST_OPTIONS_DISPLAY_CONTRAST;
    }

    return ST_OPTIONS_DISPLAY_CONTRAST_FUNC;
}

#endif
// REDUCED

mian.c

/*
  《AVR专题精选》随书例程
  
  3.通信接口使用技巧

  项目:使用USI作为主SPI接口
  文件:main.c
  说明:主程序文件. 在AVR Bufferfly上演示USI做主SPI接口用法
        控制EEPROM 25AA010
        按键: 上  数据加
              下  数据减
              左  读取数据
              右  写数据
              中  随机数据
        
  作者:邵子扬
  时间:2012年12月15日

*/
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <inttypes.h>
#include <stdio.h>

// 系统时钟频率
#define F_CPU 1000000UL

#include <util/delay.h>

#include "LCD_functions.h"
#include "LCD_driver.h"

#include "macromcu.h"

// 定义端口
#define SS   B, 0
#define SCK  E, 4
#define MOSI E, 6
#define MISO E, 5

// SPI初始化
void SPI_init()
{
  PINSET(SS);
  USIDR = 0;
  USISR = (1<<USIOIF);
  USICR = (1<<USIWM0)|(1<<USICLK)|(1<<USICLK);
}

// SPI读写函数
unsigned char SPI_WR(unsigned char dat)
{
  unsigned char i;

  USIDR = dat; // 数据放入USI数据寄存器
  for(i = 0; i < 8; i++)  // 软件方式驱动时钟信号
  {
    USICR = (1<<USIWM0)|(1<<USITC);
    USICR = (1<<USIWM0)|(1<<USITC)|(1<<USICLK);
  }

  return USIDR; // 返回数据
}

// 按键掩码
#define PINB_MASK ((1<<PINB4)|(1<<PINB6)|(1<<PINB7))
#define PINE_MASK ((1<<PINE2)|(1<<PINE3))

// 读取按键状态
unsigned char getkey()
{
  unsigned char t;

  t = (~PINB) & PINB_MASK;
  t |= (~PINE) & PINE_MASK;

  return t;
}

unsigned char dat = 0, cnt;
char s[] = "    00";

// HEX数据转换为字符
unsigned char hexchr(unsigned char dat)
{
  if(dat > 15)
    return '0';

  if(dat < 10)
    return dat + '0';
  else
    return dat - 10 + 'A';
}

// HEX数据转换字符串
void hexbuf(unsigned char dat, char *buf)
{
  buf[0] = hexchr(dat/16);
  buf[1] = hexchr(dat%16);
}

// 从EEPROM地址0读取一个字节
unsigned char ReadByte()
{
  unsigned char t;

  PINCLR(SS);    // 片选信号

  SPI_WR(0x03);  // 发读命令
  SPI_WR(0x00);  // 地址高位
  SPI_WR(0x00);  // 地址低位
  t = SPI_WR(0); // 数据

  PINSET(SS);    // 禁止片选

  return t;
}

// 写入一个字节到EEPROM地址0
void WriteByte(unsigned char dat)
{
  PINCLR(SS);    // 使能片选

  SPI_WR(0x02);  // 发送写命令
  SPI_WR(0x00);  // 地址高位
  SPI_WR(0x00);  // 地址低位
  SPI_WR(dat);   // 数据

  PINSET(SS);    // 禁止片选
}

// 允许写入EEPROM
void WREN(void)
{
  PINCLR(SS);    // 片选

  SPI_WR(0x06);  // 发送wren命令

  PINSET(SS);  
}

// 主程序
int main()
{
  // IO 初始化
  PINDIR(SS,   PIN_OUTPUT);
  PINDIR(SCK,  PIN_OUTPUT);
  PINDIR(MOSI, PIN_OUTPUT);
  PINDIR(MISO, PIN_OUTPUT);

  PORTB |= PINB_MASK;
  PORTE |= PINE_MASK;

  // SPI初始化
  SPI_init(0, 0);

  // AVR Butterfly LCD初始化
  LCD_Init();
  
  // 开中断
  sei();

  // 显示地址和数据
  hexbuf(dat, s+4);
  LCD_puts(s, 0);

  while(1)
  {
    _delay_ms(200);  // 延时
    cnt++;
    if(getkey())     // 读取按键
    {
      switch(getkey())
      {
        case 0x40://up
          dat++;     // 数据递增
          s[0] = ' ';
          break;
        case 0x80://dn
          dat--;     // 数据递减
          s[0] = ' ';
          break;
        case 0x04://left
          s[0] = 'R';  // 左键代表读取数据
          dat = ReadByte();
          break;
        case 0x08://right
          s[0] = 'W';  // 右键写入数据
          WREN();
          WriteByte(dat);
          break;
        case 0x10://enter
          //dat = ReadStatus();
          //hexbuf(dat, s+2);
          dat = cnt;    // 回车键随机设置数据
          break;
      }
      hexbuf(dat, s+4);
      LCD_puts(s, 0);
    }
  }

  return 0;
}

仿真效果图:

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/735611.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

UltraEditUEStudio软件安装包下载及安装教程

​根据软件大数据显示提供预定义的或使用者创建的编辑“环境”&#xff0c;能记住 UltraEdit 的所有可停靠窗口、工具栏等的状态。实际上我们可以这样讲HTML 工具栏&#xff0c;对常用的 HTML 功能作了预配置;文件加密/解密;多字节和集成的 IME。根据使用者情况表明Git Editor&…

day41--Redis(三)高级篇之最佳实践

Redis高级篇之最佳实践 今日内容 Redis键值设计批处理优化服务端优化集群最佳实践 1、Redis键值设计 1.1、优雅的key结构 Redis的Key虽然可以自定义&#xff0c;但最好遵循下面的几个最佳实践约定&#xff1a; 遵循基本格式&#xff1a;[业务名称]:[数据名]:[id]长度不超过…

【Linux系列】find命令使用与用法详解

&#x1f49d;&#x1f49d;&#x1f49d;欢迎来到我的博客&#xff0c;很高兴能够在这里和您见面&#xff01;希望您在这里可以感受到一份轻松愉快的氛围&#xff0c;不仅可以获得有趣的内容和知识&#xff0c;也可以畅所欲言、分享您的想法和见解。 推荐:kwan 的首页,持续学…

动手学深度学习(Pytorch版)代码实践 -卷积神经网络-26网络中的网络NiN

26网络中的网络NiN import torch from torch import nn import liliPytorch as lp import matplotlib.pyplot as plt# 定义一个NiN块 def nin_block(in_channels, out_channels, kernel_size, strides, padding):return nn.Sequential(# 传统的卷积层nn.Conv2d(in_channels, ou…

兰州理工大学24计算机考研情况,好多专业都接受调剂,只有计算机专硕不接收调剂,复试线为283分!

兰州理工大学&#xff08;Lanzhou University of Technology&#xff09;&#xff0c;位于甘肃省兰州市&#xff0c;是甘肃省人民政府、教育部、国家国防科技工业局共建高校&#xff0c;甘肃省高水平大学和“一流学科”建设高校&#xff1b;入选国家“中西部高校基础能力建设工…

年薪50w+的项目经理,手把手教你如何复盘

复盘是一种重要的学习和改进工具&#xff0c;对于项目经理来说&#xff0c;能帮助识别项目中的成功与失败&#xff0c;为未来的项目管理提供宝贵经验。 理论部分 定义目标。在开始复盘之前&#xff0c;明确复盘的目标是什么。是为了找出项目中的问题并提出解决方案&#xff0c…

Open MMLab 之 MMDetection3D框架

MMDetection框架入门教程&#xff08;完全版&#xff09;-CSDN博客 OpenMMLab MMDetection是商汤和港中文大学针对目标检测任务推出的一个开源项目&#xff0c;它基于Pytorch实现了大量的目标检测算法&#xff0c;把数据集构建、模型搭建、训练策略等过程都封装成了一个个模块…

Chromium 调试指南2024 Mac篇 - 准备工作 (一)

1.引言 Chromium是一个由Google主导开发的开源浏览器项目&#xff0c;它为Google Chrome浏览器提供了基础框架。Chromium不仅是研究和开发现代浏览器技术的重要平台&#xff0c;还为众多其他基于Chromium的浏览器&#xff08;如Microsoft Edge、Brave等&#xff09;提供了基础…

基于Openmv的色块识别代码及注意事项

在给出代码之前我先说注意事项以及需要用到的函数 1、白平衡和自动增益的关闭 打开白平衡和自动增益会影响颜色识别的效果&#xff0c;具体影响体现在可能使你颜色阈值发生改变 关闭代码如下 sensor.set_auto_gain(False) #关闭自动增益 sensor.set_whitebal(False) …

【笔记】HashMap的头插死循环问题

HashMap头插死循环是指在JDK1.7中&#xff0c;多线程环境下&#xff0c;HashMap进行扩容时由于多个线程一起执行扩容&#xff0c;可能会导致某一结点被错误插入头部并形成一个循环链表。 发生死循环的源码如下&#xff1a; // hashmap由数组链表构成 void transfer(Entry[] ne…

MySQL进阶——触发器

目录 1介绍 2语法 3案例 3.1 insert插入数据类型 3.2 update修改数据类型 3.3 delete删除数据类型 4视图/存储过程/触发器—小结 1介绍 触发器是与表有关的数据库对象&#xff0c;指在insert/update/delete之前(BEFORE)或之后(AFTER)&#xff0c;触发并执行触发器中定义…

mysql启动时遇到:本地计算机上的MySQL服务启动后停止

1.问题重述&#xff1a; 今早启动数据库时发现无法启动&#xff0c;报错&#xff1a;本地计算机 上的 MySQL服务启动后停止。某些服务在未由其他服务或程序使用时将自动停止。 2.解决方案&#xff1a; 1.数据备份&#xff1a; 2.在bin目录下&#xff0c;命令行中输入 mysqld …

认识微服务

单体架构 单体架构&#xff1a;将业务的所有功能集中在一个项目中开发&#xff0c;打成一个包部署。 优点&#xff1a; 架构简单部署成本低缺点&#xff1a; 团队协作成本高系统发布效率低系统可用性差 总结&#xff1a; 单体架构适合开发功能相对简单&#xff0c;规模较小…

上位机图像处理和嵌入式模块部署(mcu开发注意事项)

【 声明&#xff1a;版权所有&#xff0c;欢迎转载&#xff0c;请勿用于商业用途。 联系信箱&#xff1a;feixiaoxing 163.com】 mcu的种类很多&#xff0c;生产的厂家很多。这里面有进口的&#xff0c;有国产的&#xff0c;并且国产替代的趋势越来越明显。但是&#xff0c;不管…

我国人工智能核心产业规模近6000亿元

以下文章来源&#xff1a;中国证券报 2024世界智能产业博览会6月20日至6月23日在天津举行。会上发布的《中国新一代人工智能科技产业发展报告2024》显示&#xff0c;我国人工智能企业数量已经超过4000家&#xff0c;人工智能已成为新一轮科技革命和产业变革的重要驱动力量和战略…

SAP PP学习笔记22 - 生产订单(制造指图)的元素1

前面几章讲了PP 里面生产计划的各种策略以及策略的Customize。 SAP PP学习笔记20 - 复习总结一下MTS&#xff0c;MTO&#xff0c;ATO的各种生产策略-CSDN博客 SAP PP学习笔记21 - 计划策略的Customize&#xff1a;策略组 &#xff1e; 策略 &#xff1e; 需求类型 &#xff1…

Java——集合(一)

前言: Collection集合&#xff0c;List集合 文章目录 一、Collection 集合1.1 集合和数组的区别1.2 集合框架1.3 Collection 集合常用方法1.4 Collction 集合的遍历 二、List 集合2.1 List 概述2.2 List集合的五种遍历方式2.3 List集合的实现类 一、Collection 集合 1.1 集合和…

正则表达式,linux文本三剑客

正则表达式匹配的是文本内容&#xff0c;linux的文本三剑客都是针对文本内容&#xff0c;按行进行匹配 文本三剑客&#xff1a; grep 过滤文本内容 sed 针对文本内容进行增删改查 awd 按行取列 一.grep命令 作用就是使用正则表达式来匹配文本内容 -m 数字&#xff1a;匹配…

什么是深度神经网络?与深度学习、机器学习、人工智能的关系是什么?

什么是深度神经网络&#xff1f;与深度学习、机器学习、人工智能的关系是什么&#xff1f; &#x1f916;什么是深度神经网络&#xff1f;与深度学习、机器学习、人工智能的关系是什么&#xff1f;摘要引言正文内容1. 什么是深度神经网络&#xff1f;&#x1f9e0;1.1 深度神经…

git拉取gitee项目到本地

git安装等不做赘述。 根据需要选择不同操作 1.只是单纯拉取个项目&#xff0c;没有后续的追踪等操作 不需要使用git init初始化本地文件夹 新建一个文件夹用于存储项目&#xff0c;右键选择 git bash here 会出现命令行窗口 如果像我一样&#xff0c;只是拉取个项目作业&…