Приветстую люди.. если не затруднит.. сваял племяшу приблуду на матрице 8х8 и меге8 по общедоступному проекту из инета.. https://cxem.net/mc/mc61.php родная прошивка из проекта не работает с моей матрицей почему то(CPD-15088AYGD2/A), какие то тени показывает.. может по пинам что ли не сошлось.. решил поковырять исходник - првести распиновку в соответствии с моей(т.к плата уже спаяна), но вот исходник на BascomAVR собираться не хочет.. ошибки на скрине ниже.. укажите plz как поправить, был бы признателен... код
Спойлер
Код:
'******************************************************************************* '---------- светодиодов 8x8 HID на USB----------------------------- '*******************************************************************************
'BASCOM-AVR v.2.0.5.0 'Rubashka Vasiliy 'Ukraine '2011 '$prog &HFF , &HFF , &HD9 , &HFF 'Take care that the chip supports all fuse bytes.
'Include the software USB library - NEW $lib "swusb.lbx" $external _swusb $external Crcusb Declare Function Crcusb(buffer() As Byte , Count As Byte) As Word
Declare Sub Usb_reset() Declare Sub Usb_processsetup(txstate As Byte) Declare Sub Usb_send(txstate As Byte , Byval Count As Byte) Declare Sub Usb_senddescriptor(txstate As Byte , Maxlen As Byte)
'*************************** Конфигурация USB ********************************** ' 'Set the following parameters to match your hardware configuration and USB 'device parameters.
'******************************* USB Connections *******************************
'Define the AVR port that the two USB pins are connected to _usb_port Alias Portd _usb_pin Alias Pind _usb_ddr Alias Ddrd
'Define the D+ and D- pins. (put D+ on an interrupt pin) Const _usb_dplus = 2 Const _usb_dminus = 4
' USB Connector: ' ---------- ' 1 (red) +5V ' 2 (white) DATA- ' 3 (green) DATA+ ' 4 (black) GND ' +--*----------*---------*----------+ ' 0,1| | | | ATMEGA 8 | ' --- | +-----+---[1k5]-+ +--\/--+ | ' USB --- | | +---[10k]---*--|1 28| | ' | | CAPS | | |2 27| | ' /---\ | | NUM | | |3 26| | ' | VCC|-1-+--+ +------+---------[68r]---+--|4 25| | ' \ | | | LOCK | | |5 24| | ' |D-|-2-+--*-+------*---------[68r]---+--|6 23| | ' | | | | | +--+--|7 22|--------+-+ ' |D+|-3-+--+-*-L<|----*----------+--+--|8 21| | | ' / | | | | +----------+--+--|9 20|--------* | ' | GND|-4-* +---L<|----* | === +--+--+--|10 19|------+ | | ' \---/ | 2x3,6v | +-12MHz-+ | | |11 18|----+ | | | ' | | === | | |12 17|--+ | | | | ' +----------* | | |13 16| | | | | | ' | | | |14 15| | | | | | ' | | | +------+ | | | | | ' | | +----------+ | | | | | ' | *-------*-----+-+-+-+-* | ' | |0,1 +|22,0 | | | | | | ' | --- --- | | | | | | ' | --- --- | | | | | | ' | | | | | | | | | ' *----------*-------*-----+-+-+-+-+-* ' | | | | | | | ' === V V V V V V ' ' R M M S V G ' E O I C C N ' S S S K C D
'Configure the pins as inputs
Ddrb = &B11111111 'направление линий порта B: 1 - на вывод Portb = &B00000000 'исходное состояние линий B: 00000000 Ddrc = &B11111111 'направление линий порта C: 1 - на вывод Portc = &B00000000 'исходное состояние линий C: 00000000 Ddrd = &B11101011 'направление линий порта D: 1 - на вывод Portd = &B00000000 'исходное состояние линий D: 00000000
'---------- строк------------------------------ 1str Alias Portd.5 2str Alias Portc.4 3str Alias Portd.7 4str Alias Portc.5 5str Alias Portb.4 6str Alias Portb.0 7str Alias Portc.0 8str Alias Portb.1 '---------- столбцов----------------------------- 1stl Alias Portb.5 2stl Alias Portc.3 3stl Alias Portd.0 4stl Alias Portb.2 5stl Alias Portd.6 6stl Alias Portb.3 7stl Alias Portc.1 8stl Alias Portc.2
'************************* USB константы конфигурации **************************
'Использовать EEPROM или FLASH для хранения USB дескрипторов '1 = EEPROM, 0 = FLASH. Использование EEPROM немного уменьшит размер кода. Const _usb_use_eeprom = 1
'Don't wait for sent packets to be ACK'd by the host before marking the 'transmission as complete. This option breaks the USB spec but improves 'throughput with faster polling speeds. 'This may cause reliability issues. Should leave set to 0 to be safe. Const _usb_assume_ack = 1
'USB Vendor ID and Product ID (Assigned by USB-IF) Const _usb_vid = &HFFFF Const _usb_pid = &H5555
'USB Device Release Number (BCD) Const _usb_devrel = &H0001
'USB Release Spec (BCD) Const _usb_spec = &H0110
'USB Device Class, subclass, and protocol (assigned by USB-IF). '&h00 = Class defined by interface. (HID is defined in the interface) '&hFF = Vendor-defined class (You must write your own PC driver) 'See http://www.usb.org/developers/defined_class for more information Const _usb_devclass = 0 Const _usb_devsubclass = 0 Const _usb_devprot = 0
'These are _indexes_ to UNICODE string descriptors for the manufacturer, 'product name, and serial number. 0 means there is no descriptor. Const _usb_imanufacturer = 1 Const _usb_iproduct = 2 Const _usb_iserial = 0
'Количество конфигураций для этого устройства. Не изменяйте это если, 'вы не знаете то, что Вы делаете! Обычно равно 1 Const _usb_numconfigs = 1
'Число интерфейсов для этого устройства (1 или 2) Const _usb_ifaces = 1
'Номер интерфейса Const _usb_ifaceaddr = 0
'Альтернативный индекс Const _usb_alternate = 0
'Количество конечных точек для этого интерфейса (исключая нулевую) Const _usb_ifaceendpoints = 2
'USB класс интерфейса, подкласс, и протокол (назначенное USB-IF). '&h00 = RESERVED '&hFF = Vendor-defined class (You must write your own PC driver) ' Other values are USB interface device class. (such as HID) 'See http://www.usb.org/developers/defined_class for more information Const _usb_ifclass = 3 Const _usb_ifsubclass = 0 Const _usb_ifprotocol = 0
'Индекс в дескрипторе строки УНИКОДА для этого интерфейса (0 - отсутствует) Const _usb_iiface = 0
'*************************** Дополнительный HID дескриптор ********************* 'HID класс, устройств являются вещами подобно клавиатуре, мыши, джойстику. 'See http://www.usb.org/developers/hidpage/ for the specification, 'tools, and resources.
'Учтите, что для устройства HID, класс устройства, подкласс, и протокол 'должен быть 0. Класс интерфейса должен быть 3 (HID). 'Подкласс Интерфейса и протокола должны быть 0 если Вы не делаете 'клавиатурой или мышь, которые поддерживают встроенный протокол. 'Смотрите страницы 8 и 9 спецификации HID 1.11 PDF.
'Число HID дескриптора (EXCLUDING report and physical) 'Если Вы не делаете устройство HID, тогда установите эту константу на 0 Const _usb_hids = 1
'BCD HID releasenumber. Current spec is 1.11 Const _usb_hid_release = &H0111
'Country code from page 23 of the HID 1.11 specifications. 'Usually the country code is 0 unless you are making a keyboard. Const _usb_hid_country = 0
' Номер сообщения и физических дескрипторов для этого HID ' Должно быть в 1! Все HID устройства иметь по крайней мере 1 дескриптор сообщения. Const _usb_hid_numdescriptors = 1
'Use a software tool to create the report descriptor and $INCLUDE it.
'*************************** Дескриптор конечной точки *************************
'Конечная точка 0 не включается здесь. Эти - только для других 'конечных точек. 'Примечание: HID устройства требуют 1 прерывание В конечной точке
'Адрес дополнительных конечных точек (Должно быть > 0. сделать комментарием, если не требуется) Const _usb_endp2addr = 1 Const _usb_endp3addr = 2
'Правильные типы - 0 для управления или 3 для прерывания Const _usb_endp2type = 3 Const _usb_endp3type = 3
'Направление: 0=Out (от компа), 1=In (в комп). Проигнорированно управляющими конечными точками Const _usb_endp2direction = 1 Const _usb_endp3direction = 0
' Интервал опроса (мс) для конечных точек прерывания. ' Проигнорированно управляющими конечными точками ' (Должно быть не менее 10) Const _usb_endp2interval = 10 Const _usb_endp3interval = 10
'******************************************************************************* 'The includes need to go right here--between the configuration constants above 'and the start of the program below. The includes will automatically calculate 'constants based on the above configuration, dimension required variables, and 'allocate transmit and receive buffers. Nothing inside the includes file needs 'to be modified. $include "Const_swusb-includes.bas" '*******************************************************************************
'**************************** USB Interrupt And Init *************************** 'Инициализация всех переменных, флагов, и бит синхронизации Call Usb_reset() Const _usb_intf = Intf0 Config Int0 = Rising On Int0 Usb_isr Nosave Enable Int0
Enable Interrupts 'Разрешить все прерывания
'*************************** Завершение концигурации USB *********************** '*******************************************************************************
Dim Resetcounter As Word Dim Idlemode As Byte
Dim W As Byte 'Частота обновления индикатора Dim Inp1 As Byte Dim Inp2 As Byte Dim Inp3 As Byte Dim Inp4 As Byte Dim Inp5 As Byte Dim Inp6 As Byte Dim Inp7 As Byte Dim Inp8 As Byte
'******************************* Основной цикл ********************************* Do Call Indication 'Индикация матрицы светодиодов
Resetcounter = 0
'Флаг сброса While _usb_pin._usb_dminus = 0 Incr Resetcounter If Resetcounter = 1000 Then Call Usb_reset() End If Wend
'Флаг полученных данных If _usb_status._usb_rxc = 1 Then
If _usb_status._usb_setup = 1 Then 'Обработка пакет/управление сообщения установки Call Usb_processsetup(_usb_tx_status) Elseif _usb_status._usb_endp1 = 1 Then ' Пришёл пакет данных с компа
If Ind = 0 Then Inp8 = _usb_rx_buffer(2) If Ind = 1 Then Inp7 = _usb_rx_buffer(2) If Ind = 2 Then Inp6 = _usb_rx_buffer(2) If Ind = 3 Then Inp5 = _usb_rx_buffer(2) If Ind = 4 Then Inp4 = _usb_rx_buffer(2) If Ind = 5 Then Inp3 = _usb_rx_buffer(2) If Ind = 6 Then Inp2 = _usb_rx_buffer(2) If Ind = 7 Then Inp1 = _usb_rx_buffer(2) Incr Ind If Ind = 8 Then Ind = 0
End If
'Восстановление бита RXC и установка бита RTR (готовность получить новый пакет) _usb_status._usb_rtr = 1 _usb_status._usb_rxc = 0 End If
'******************************************************************************* '**************** Дескрипторы, сохранённые в EEPROM или FLASH ****************** ' Не изменять порядок дескрипторов! ' #if _usb_use_eeprom = 1 $eeprom #else $data #endif
'Дескрипторы устройства _usb_devicedescriptor: Data 18 , 18 , _usb_desc_device , _usb_specl , _usb_spech , _usb_devclass Data _usb_devsubclass , _usb_devprot , 8 , _usb_vidl , _usb_vidh , _usb_pidl Data _usb_pidh , _usb_devrell , _usb_devrelh , _usb_imanufacturer Data _usb_iproduct , _usb_iserial , _usb_numconfigs
'Retrieving the configuration descriptor also gets all the interface and 'endpoint descriptors for that configuration. It is not possible to retrieve 'only an interface or only an endpoint descriptor. Consequently, this is a 'large transaction of variable size.
_usb_configdescriptor: Data _usb_descr_total , 9 , _usb_desc_config , _usb_descr_totall Data _usb_descr_totalh , _usb_numifaces , _usb_confignum , _usb_iconfig Data _usb_powered , _usb_maxpower
'_usb_IFaceDescriptor Data 9 , _usb_desc_iface , _usb_ifaceaddr , _usb_alternate Data _usb_ifaceendpoints , _usb_ifclass , _usb_ifsubclass , _usb_ifprotocol Data _usb_iiface
#if _usb_hids > 0 '_usb_HIDDescriptor Data _usb_hid_descr_len , _usb_desc_hid , _usb_hid_releasel , _usb_hid_releaseh Data _usb_hid_country , _usb_hid_numdescriptors
'Next follows a list of bType and wLength bytes/words for each report and 'physical descriptor. There must be at least 1 report descriptor. In practice, 'There are usually 0 physical descriptors and only 1 report descriptor.
Data _usb_desc_report Data 33 , 0 ' первое число должно быть таким же, как количество данных дескриптора HID - _usb_hid_reportdescriptor 'End of report/physical descriptor list #endif
#if _usb_endpoints > 1 '_usb_EndpointDescriptor Data 7 , _usb_desc_endpoint , _usb_endp2attr , _usb_endp2type , 8 , 0 Data _usb_endp2interval #endif
#if _usb_endpoints > 2 '_usb_EndpointDescriptor Data 7 , _usb_desc_endpoint , _usb_endp3attr , _usb_endp3type , 8 , 0 Data _usb_endp3interval #endif
#if _usb_hids > 0 _usb_hid_reportdescriptor: 'Дескриптор нестандартного HID-устройства Data 33 ' Length = 33 bytes Data &H06 , &H00 , &HFF ' Usage_page(vendor Defined Page 1) Data &H09 , &H01 ' Usage(vendor Usage 1) Data &HA1 , &H01 ' Collection(logical)
Data &H09 , &H01 ' Usage(pointer) Data &H15 , &H00 ' Logical_minimum(0) Data &H25 , &HFF ' Logical_maximum(255) Data &H75 , &H08 ' Report_size(8) Data &H95 , &H01 ' Report_count(!!! 1 байта на передачу) Data &H81 , &H02 ' Input(data , Var , Abs)
Data &H09 , &H01 ' Usage(pointer) Data &H15 , &H00 ' Logical_minimum(0) Data &H26 , &HFF , 0 ' Logical_maximum(255) Data &H75 , &H08 ' Report_size(8) Data &H95 , &H01 ' Report_count(!!! 8 байта на прием) Data &H91 , &H02 ' Output(data , Var , Abs) Data &HC0 ' End_collection
#endif
'*****************************String descriptors******************************** ' Yes, they MUST be written like "t","e","s","t". Doing so pads them with ' 0's. If you write it like "test," I promise you it won't work. ' Нужно писать так: "t","e","s","t". ' Если написать "test," - работать не будет
'Default language descriptor (index 0) 'Дескриптор языка по умолчанию (индекс 0) _usb_langdescriptor: Data 4 , 4 , _usb_desc_string , 09 , 04 '&h0409 = English 'Data 4 , 4 , _usb_desc_string , 19 , 04 '&h0419 = Русский
'Manufacturer Descriptor (unicode) 'Дескриптор изготовителя (unicode) _usb_mandescriptor: Data 13 , 13 , _usb_desc_string Data "R" , "a" , "d" , "a" , "n" , 0
'Product Descriptor (unicode) 'Дескриптор продукта (unicode) _usb_proddescriptor: Data 31 , 31 , _usb_desc_string Data "L" , "E" , "D" , " " , "M" , "A" , "T" , "R" , "I" , "X" , " " , "8" , "x" , "8" , 0
'Дескриптор номера _usb_numdescriptor: Data 5 , 5 , _usb_desc_string Data "1" , 0
Sub Usb_processsetup(txstate As Byte) Senddescriptor = 0
'Control transfers reset the sync bits like so Txstate = _usb_setup_sync
'These are the standard device, interface, and endpoint requests that the 'USB spec requires that we support. Select Case _usb_rx_buffer(2) 'Стандартные запросы устройств Case &B10000000: Select Case _usb_rx_buffer(3) ' Case _usb_req_get_status: ' 00 - Определение состояния устройства
End Select End Select ' CASE _usb_REQ_GET_CONFIG: End Select Case &B00000000: Select Case _usb_rx_buffer(3) ' CASE _usb_REQ_CLEAR_FEATURE: ' 01 Сброс устройства ' CASE _usb_REQ_SET_FEATURE: ' 03 Установить свойство Case _usb_req_set_address: 'USB status reporting for control writes Call Usb_send(txstate , 0) While Txstate._usb_txc = 0 : Wend 'We are now addressed. _usb_deviceid = _usb_rx_buffer(4) ' CASE _usb_REQ_SET_DESCRIPTOR: Case _usb_req_set_config: 'Have to do status reporting Call Usb_send(txstate , 0) End Select 'Стандартные запросы интерфейса Case &B10000001: Select Case _usb_rx_buffer(3) ' CASE _usb_REQ_GET_STATUS: ' CASE _usb_REQ_GET_IFACE: Case _usb_req_get_descriptor '_usb_rx_buffer(4) Индекс дескриптора и (5) его тип Select Case _usb_rx_buffer(5) Case _usb_desc_report: #if _usb_use_eeprom = 1 Readeeprom _usb_eepromaddrl , _usb_hid_reportdescriptor #else Restore _usb_hid_reportdescriptor #endif Senddescriptor = 1
' CASE _usb_DESC_PHYSICAL
' CASE _USB_DESC_HID
End Select End Select Case &B00100001: 'Class specific SET requests Select Case _usb_rx_buffer(3) 'CASE _usb_REQ_SET_REPORT: Case _usb_req_set_idle: Idlemode = 1 'Do status reporting Call Usb_send(txstate , 0) 'CASE _usb_REQ_SET_PROTOCOL: End Select End Select
If Senddescriptor = 1 Then Call Usb_senddescriptor(txstate , _usb_rx_buffer(8)) End If
End Sub
Sub Usb_senddescriptor(txstate As Byte , Maxlen As Byte)
'Break the descriptor into packets and send to TxState Local Size As Byte Local I As Byte Local J As Byte Local Timeout As Word
#if _usb_use_eeprom = 1 'EEPROM access is a little funky. The size has already been fetched 'and stored in _usb_EEPROMADDRL, and the address of the descriptor 'is now in the EEAR register pair.
Size = _usb_eepromaddrl
'Fetch the location of the descriptor and use it as an address pointer
push R24 in R24, EEARL sts {_USB_EEPROMADDRL}, R24 in R24, eearH sts {_USB_EEPROMADDRH}, R24 pop R24
#else Read Size #endif
If Maxlen < Size Then Size = Maxlen
I = 2 For J = 1 To Size Incr I #if _usb_use_eeprom = 1 Incr _usb_eepromaddr Readeeprom Txstate(I) , _usb_eepromaddr #else Read Txstate(I) #endif
If I = 10 Or J = Size Then I = I - 2 Call Usb_send(txstate , I) While Txstate._usb_txc = 0 Timeout = 0 'To prevent an infinite loop, check for reset here While _usb_pin._usb_dminus = 0 Incr Timeout If Timeout = 1000 Then ' Call Usb_reset() Exit Sub End If Wend Wend I = 2 End If Next End Sub
Sub Usb_send(txstate As Byte , Byval Count As Byte)
'Calculates and adds the CRC16,adds the DATAx PID, 'and signals to the ISR that the data is ready to be sent. ' '"Count" is the DATA payload size. Range is 0 to 8. Do not exceed 8!
'Reset all the flags except TxSync and RxSync Txstate = Txstate And _usb_syncmask
'Calculate the 16-bit CRC _usb_crc = Crcusb(txstate(3) , Count)
'Bytes to transmit will be PID + DATA payload + CRC16 Count = Count + 3 Txstate = Txstate + Count
Txstate(count) = Low(_usb_crc) Incr Count Txstate(count) = High(_usb_crc) 'Add the appropriate DATAx PID Txstate(2) = _usb_pid_data1 If Txstate._usb_txsync = 0 Then Txstate(2) = _usb_pid_data0 End If 'The last step is to signal that the packet is Ready To Transmit Txstate._usb_rtt = 1 Txstate._usb_txc = 0 End Sub
Sub Usb_reset() 'Reset the receive flags _usb_status._usb_rtr = 1 _usb_status._usb_rxc = 0 'Reset the transmit flags _usb_tx_status = _usb_endp_init #if Varexist( "_usb_Endp2Addr") _usb_tx_status2 = _usb_endp_init #endif #if Varexist( "_usb_Endp3Addr") _usb_tx_status3 = _usb_endp_init #endif 'Reset the device ID to 0 _usb_deviceid = 0 Idlemode = 0 End Sub
это для вас "элементарно", я этот баском только вчера поставил
Мы вообще не знаем Bascom. И никогда не работали с ним. Опыт Вашей работы с ним, получается, многократно превышает наш.
AndyGU70 писал(а):
END Sub в коде присутствует..
я не говорил это. Я даже строку указал: If Maxlen < Size Then Size = Maxlen. Её номер примерно 857 (файл же не надо прикладывать, нахер он нужен, пусть все мучаются в портянках в спойлере) Какой нафиг END Sub?
Чем передаваемый массив не нравится - сами разбирайтесь. Читать же умеете. А то опять капитаном назовёте, что в принципе неправда - моё звание - старшина второй статьи, и капитана получить не смогу из-за отсутствия высшего образования.
Martian, обмудок ты, а не "старшина второй статьи".. если сказать нехер, пройди мимо, за умного сойдешь.. Из за таких бесов с завышенным самомнением и не хочется иногда ничего спрашивать на форумах..
Martian, обмудок ты, а не "старшина второй статьи".. если сказать нехер, пройди мимо, за умного сойдешь.. Из за таких бесов с завышенным самомнением и не хочется иногда ничего спрашивать на форумах..
А ты что сорвался? Тормозные колодки сорваны? У тебя проблема. Вопрос. Тебе вполне корректно ответили. А ты сразу на личности перешёл. Этта. Друг. Не надо. Ты с проблемой. И стал хамить. Либо осади своего орангутана. Либо иди ка ты лесом. По твоему вопросу. Баском. Мало кто работает в нем. Ассемблер, си в основном. Хочешь решить проблему. С тебя нормальное ТЗ. Фото, видео. Успехов!
Заголовок сообщения: Re: Дайте разьяснение :) не компилится...
Добавлено: Сб июн 01, 2024 08:09:17
Вымогатель припоя
Карма: 1
Рейтинг сообщений: 129
Зарегистрирован: Вт мар 03, 2015 20:13:46 Сообщений: 617 Откуда: рядом с "не резиновой" живу в деревне
Рейтинг сообщения:0
Почитал статью по ссылке тс - вступление о причинах возникновения этого устройства жесть. Нубля это реально укуренная норкоманская приблуда, так и чо удивляться - ЭТО притягивает особый контингент - склонный к перепадам настроения и не мотивированной агрессии.
Вы не можете начинать темы Вы не можете отвечать на сообщения Вы не можете редактировать свои сообщения Вы не можете удалять свои сообщения Вы не можете добавлять вложения